long :
Date startDate1 = new Date(1284245999999L);
Date startDate2 = new Date(1284246000000L);
System.out.println(startDate1);
System.out.println(startDate2);
Date endDate = new Date(1321919999000L);
System.out.println(endDate);
:
Sun Sep 12 01:59:59 IDT 2010
Sun Sep 12 01:00:00 IST 2010 <-- Long value is greater, but due to DST changes, actual time is one hour earlier
Tue Nov 22 01:59:59 IST 2011
Please note that incrementing long 1from from 1284245999999Lto 1284246000000Lreturns us "back in time" due to the transition from standard time to daylight saving time.
This is how Java time calculation behaves - the number of milliseconds has not changed since January 1, 1970, but the time it represents is based on the time zone.
source
share