I'm running into a problem when I construct a DateTime (or LocalDate). I'm converting old code to use joda internally to make things more sane. However I'm running into the +1900 issue...
This passes:
assertEquals(2082, new Date(2082, 1, 1).getYear());
These both fail:
assertEquals(2083, new LocalDate(new Date(2083, 1, 1)).getYear());
assertEquals(2084, new DateTime(new Date(2084, 1, 1)).toLocalDateTime().getYear());
What's going on here? How do I get a DateTime from a Date object?
From javadoc for
java.util.Date(int year, int month, int date)
:Besides the fact that it states that the years argument is an offset from the year 1900, you should not be using this constructor as it's deprecated. Instead, use
java.util.Calendar
: