Problem converting java.util.Date to org.joda.time.LocalDateTime
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
import org.joda.time.LocalDateTime;
import java.util.Date;
With this date or with the following ones it's all OK:
new LocalDateTime(new Date(0,0,1,2,30))— 1900-01-01T02:30:00.000new LocalDateTime(new Date(111,4,24,19,51))— 2011-05-24T19:51:00.000
But there is something incomprehensible with preceding dates:
new LocalDateTime(new Date(0,0,1,2,29,50))— 1900-01-01T01:59:50.000new LocalDateTime(new Date(0,0,1))— 1899-12-31T23:30:00.000new LocalDateTime(new Date(-50,0,1))— 1849-12-31T23:30:20.000new LocalDateTime(new Date(-116,6,4))— 1784-07-03T23:30:20.000
Who knows, what is this, and how to prevent this problem?
This question and answers originated from www.stackoverflow.com
Question by Errandir (5/24/2011 3:52:02 PM)
Answer |
Which timezone are you using? It looks like you're dealing with a clock discontinuity, possibly around 2 AM on January 1st, 1900. That means a certain amount of time was skipped by the local clock and officially doesn't exist. It could also be a change in DST. The consistent difference in your last 3 lines looks strange though - perhaps Java's Calendar and Joda Time use a different version of the timezone database and the change is missing in one of them.
You can check your timezone for changes at the linked-to site.
Answer by Michael Borgwardt
Find More Answers
Related Topics java jodatime java.util.date