Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.5k points)

I would like to have a compareTo method that ignores the time portion of a java.util.Date. I guess there are a number of ways to solve this. What's the simplest way?

1 Answer

0 votes
by (46k points)

Apache commons-lang is almost ubiquitous. 

 (DateUtils.isSameDay(date1, date2)) {

    // it's same

} else if (date1.before(date2)) {

   // it's before

} else {

   // it's after

}hat about this?

Related questions

0 votes
1 answer
0 votes
1 answer
asked Aug 10, 2019 in Java by Suresh (3.4k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 31, 2019 in Java by noah kapoor (5.3k points)

Browse Categories

...