Reputation: 14998
I'm storing DateTimes
as timestamps
in my MySQL database. Joda Time is interpreting the AM/PM part of these DateTimes
incorrectly.
DateTime dt = new DateTime(1324231621L * 1000); // long pulled from DB as timestamp
DateTimeFormatter fmt = DateTimeFormat.forPattern("h:mm aa z");
String timeStr = fmt.print(dt);
The above should result in 12:07 AM CST
but instead results in 12:07 PM CST
.
It looks like it's interpreting the hours as 24-hour based, but I'm using a lowercase "h", so I don't know why. What's the real reason?
Upvotes: 1
Views: 1260
Reputation: 1500495
I think you've got the wrong value - that timestamp is 2011-12-18T18:07:01 UTC - so it is 12:07pm in CST. If it was meant to be 12:07am, that would suggest that whatever was involved in getting it into the long form to start with is at fault - whether that's the process which put it in the database to start with, or the way that you've pulled it from the database.
Upvotes: 2