Reputation: 521
Whenever I pass time zone to create a DateTimeZone and the get the time out of it, the time returned is fluctuating. Here is my code:
TimeZone timeZone = TimeZone.getTimeZone("America/Belize");
DateTimeZone dateTimeZone = DateTimeZone.forTimeZone(timeZone);
DateTime dateTime = new DateTime(dateTimeZone);
So sometimes the time comes out correct but sometimes it is tipped one hour in the future. I notice one pattern that whenever it is wrong it is wrong by one hour in future.
Anyone has any idea why this might be happening.
I use JodaTime library for DateTimeZone and DateTime.
Upvotes: 1
Views: 380
Reputation: 35467
I suspect that you somehow look at your own timezone, look at Belize's timezone, make the difference between the two and then expect a specific hour.
Yet as Belize doesn't utilize daylight saving time and your country does, the difference sometimes shows up as one hour in the future for you. So yes, it is normal.
You're right to question Joda Time's correctness, but do it with complete information. If you really do and are still sure that there is an issue, then go on their site and file an issue. But be reassured: in pretty much all the cases, they know their timezones and daylight savings.
Upvotes: 1