I am trying to use joda-time to parse a form date string YYYY-MM-DD. I have a test code:
YYYY-MM-DD
DateTimeFormatter dateDecoder = DateTimeFormat.forPattern("YYYY-MM-DD"); DateTime dateTime = dateDecoder.parseDateTime("2005-07-30"); System.out.println(dateTime);
What outputs:
2005-01-30T00:00:00.000Z
As you can see, the created object DateTimehas a value 30 Jan 2005instead 30 July 2005.
DateTime
30 Jan 2005
30 July 2005
Appreciate any help. I just assumed that this would work because it is one of the date formats listed here .
The confusion is that it actually has an ISO format. YYYY-MM-DDnot an ISO format, the actual total date.
, 2005-07-30 ISO-8601, YYYY-MM-DD . YYYY-MM-DD . , , , , , 2- , , .
2005-07-30
, $year4-$month2-$day2, .
$year4-$month2-$day2
, "Y" "y" "D" "d".
.
: http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html
: "yyyy-MM-dd".
, w3 JodaTime DateTimeFormat, .
DateTimeFormat
, DateTimeFormat DD Day in year, DD 30 - 30- , .. 30 . String, 07. , 01 .
DD
Day in year
30
String
07
01
, DateTimeFormat, , w3 dat time.
DateTimeFormatter dateDecoder = DateTimeFormat.forPattern("yyyy-MM-dd");