I'm getting different values in milliseconds for the same date in past while using JodaTime lib and java.util.Calendar.
For example for the first year AD
void test() {
int year = 1;
DateTime dt = new DateTime(year, 1,1,0,0,0,0);
dt = dt.toDateTime(GregorianChronology.getInstance());
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(year, 0, 1, 0, 0, 0);
DateTime endDate = new DateTime(cal.getTimeInMillis());
endDate = endDate.toDateTime(GregorianChronology.getInstance());
System.out.println("JodaTime: " + dt);
System.out.println("JodaTime, ms: " + dt.getMillis());
System.out.println("Calendar: " + cal.getTime());
System.out.println("Calendar, ms: " + cal.getTimeInMillis());
System.out.println("JodaTime by Calendar: " + endDate);
}
By default DateTime use ISOChronology and Calendar is GregorianCalendar (except TH and JA locales). So I set GregorianChronology, but nothing changed.
Result of execution is
JodaTime: 0001-01-01T00:00:00.000+01:34:52
JodaTime, ms: -62135602492000
Calendar: Sat Jan 01 00:00:00 EET 1
Calendar, ms: -62135776800000
JodaTime by Calendar: 0000-12-29T23:34:52.000+01:34:52
Could someone suggest am I wrong with something?