addDays(0) changes value of MutableDateTime
Project moved to GitHub
Brought to you by:
broneill,
scolebourne
Upon DST transition from summer to winter time zone, adding the amount of zero days to a mutable date time object changes the value of the object.
The code
final MutableDateTime mdt = new MutableDateTime(2011, 10, 30, 3, 0, 0, 0, DateTimeZone.forID("Europe/Berlin"));
System.out.println("Start date: " + mdt + " (" + mdt.toInstant().getMillis() + ")");
mdt.addHours(-1);
System.out.println("addHours(-1): " + mdt + " (" + mdt.toInstant().getMillis() + ")");
mdt.addHours(0);
System.out.println("addHours(0): " + mdt + " (" + mdt.toInstant().getMillis() + ")");
mdt.addDays(0);
System.out.println("addDays(0): " + mdt + " (" + mdt.toInstant().getMillis() + ")");
prints
Start date: 2011-10-30T03:00:00.000+01:00 (1319940000000) //OK
addHours(-1): 2011-10-30T02:00:00.000+01:00 (1319936400000) //OK
addHours(0): 2011-10-30T02:00:00.000+01:00 (1319936400000) //OK, no change in time
addDays(0): 2011-10-30T02:00:00.000+02:00 (1319932800000) //error, time has changed by 1 hour
The methods addMonths and addYears show the same problem; addSeconds, addMinntes and addHours are ok.
I have tested with version 2.3. However, if I repeat the test with Joda 1.5.2, the invocation of addDays(0) does not change the date's value.
Could you please add this bug at GitHub where issues are now tracked.
https://github.com/JodaOrg/joda-time/issues?direction=desc&sort=updated&state=open
Bug added at GitHub