What is the best way of comparing two dates in jsp?
Need to know the number of days different between two dates.
Printable View
What is the best way of comparing two dates in jsp?
Need to know the number of days different between two dates.
You could use the Calendar class' method getTimeInMillis() for the two dates,
subtract them and divide the difference by number of milliseconds in 24 hrs. then add
one day if the modulus of the division is > 0
But I'm sure there are far more elegant ways to do this.
You could try useing the Calendar.compareTo(Calendar) method. THis is supposed to return the number of milliseconds between the two calendar objects.