#163 MutableDate.setDate sometimes sets wrong date

v1.0_(example)
closed
nobody
Joda-Time (76)
5
2012-10-11
2012-09-27
Anonymous
No

Setting a date with a non-UTC time zone when the UTC date at the same instant is in another date. That is setDate ignores the time zone of the parameter date and converts it to UTC. If this is intended then it should at least be documented.

Example problem:

DateTime dateTime = new DateTime("2010-10-10T04:00:00",
DateTimeZone.forID("America/Caracas"));
// time zone is -04:30 -- UTC date time is 2010-10-09T23:30

MutableDateTime mutableDateTime = dateTime.toMutableDateTime();
mutableDateTime.setDate(dateTime); // is essentially a no-op
assetEquals(dateTime, mutableDateTime);

Expected is: 2010-10-10T04:00:00.000-04:30
Actual result is: 2010-10-09T04:00:00.000-04:30

This is related to http://stackoverflow.com/questions/12623566/how-is-joda-mutabledatetimes-setdatedatetime-method-working

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-09-27

    Oh, I was using v2.1.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks