Back
The date must before and after methods and can be compared to each other as mentioned
if(todayDate.after(historyDate) && todayDate.before(futureDate)) {// In between}
if(todayDate.after(historyDate) && todayDate.before(futureDate)) {
// In between
}
For an inclusive comparison:
if(!historyDate.after(todayDate) && !futureDate.before(todayDate)) {/* historyDate <= todayDate <= futureDate */ }
if(!historyDate.after(todayDate) && !futureDate.before(todayDate)) {
/* historyDate <= todayDate <= futureDate */
You could also provide Joda-Time ago, but remark that:
Joda-Time is the de facto conventional date and time library for Java prior to Java SE 8. Users are now required to transfer to java.time (JSR-310).
Back-ports are prepared for Java 6 and 7 as great as Android
31k questions
32.8k answers
501 comments
693 users