I tried to compare the number of ms between two dates and I have problems with some specific dates. example for the 2015 february the 1st:
System.out.println(new GregorianCalendar(2015, 01, 30, 12, 0, 0).getTimeInMillis());
System.out.println(new GregorianCalendar(2015, 01, 31, 12, 0, 0).getTimeInMillis());
System.out.println(new GregorianCalendar(2015, 02, 01, 12, 0, 0).getTimeInMillis());
this returns time in ms which are not ordered chronologically:
1425294000000
1425380400000
1425207600000
I already know how to avoid the problem using another class (DateFormat). But I do not understand the problem.
31st of February doesn't exist. Month (2nd argument) of the GregorianCalendar constructor is a 0-based index. [0-11]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With