Interestingly, it works great for values ββup to (about) -10000000000000L (and positive values), but large negative values ββbecome inconsistent.
If you print gc , xc and gc2 , you can see where the problem occurs (conversion from XMLGregorianCalendar to GregorianCalendar
gc: java.util.GregorianCalendar[time=-62135740800000 ... DAY_OF_WEEK=7 xc: 0001-01-01T08:00:00.000Z gc2: java.util.GregorianCalendar[time=? ... DAY_OF_WEEK=5
If you print the xc fields, you get 1,1,1.
System.out.println(xc.getYear()); System.out.println(xc.getMonth()); System.out.println(xc.getDay());
For gc2 you will get 1,0,1 (which corresponds to xc , because months are based on a zero value in GregorianCalendar)
System.out.println(gc2.get(gc2.YEAR)); System.out.println(gc2.get(gc2.MONTH)); System.out.println(gc2.get(gc2.DAY_OF_MONTH));
However, adding these 3 calls to println changes the gc2 print gc2 ! - output time=? from gc2 changes to time=-62135568000000 - so some calculations were triggered by a GregorianCalendar object request; the areFieldsSet property also changes from false to true .
The time intervals of the two GregorianCalendars are different, but this does not take into account the error that persists, even if you set the explicit TimeZone and Locale.
DNA
source share