This is my first time using Joda-Time. Why does the month default to January? It doesn't matter what month values i enter as date including (1-12) or (Jan-Dec). All default to January.
DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy/MM/DD HH:mm:ss");
DateTime issuedTimeStamp = fmt.parseDateTime("2014/04/30 08:23:36");
System.out.println("Issued: " + issuedTimeStamp.toString());
//above prints `2014-01-30T08:23:36.000-05:00`
Ive checked my pattern which seems right. Where am i going wrong? Thank you.
You're using DD
in your format string, which means "day of year". So after parsing the month as April, you're then going to the 30th day of the year, which is in January... You want dd
, for "day of month".
When in doubt, if a format string doesn't do what you expect:
See more on this question at Stackoverflow