0 votes
1 view
in Java by (3.9k 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 (46.1k points)

Apache commons-lang is almost ubiquitous. So what about this?

if (DateUtils.isSameDay(date1, date2)) {

    // it's same

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

   // it's before

} else {

   // it's after

}

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
0 answers
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...