Reputation: 16117
Here's the string I'm trying to format
10-12-2015
Which stands for october 12 2015. However when I'm parsing it as a a LocalDate. using this
LocalDate ld = LocalDate.parse(dto.getTargetDate(), DateTimeFormat.forPattern("mm-dd-yyyy"))
the result is always 2015-01-12
What am I doing wrong?
Upvotes: 0
Views: 255
Reputation: 5548
Just change mm
to MM
, because mm
is for minutes.
Thus, when parsing you put a year equal to 2015, day to 12 and minutes to 10. All other fields are default values, month is January, hours - 00, and so on. That's why you get 12 January 2015.
Upvotes: 3