Reputation: 264
My code:
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
DateTime dt = formatter.parseDateTime("2014-04-24 18:22:01.867");
System.out.println("dt : "+dt);
Output:
dt : 2014-04-24T18:22:01.867+05:30
Expected output should be the same String
:
dt : 2014-04-24 18:22:01.867
Upvotes: 4
Views: 238
Reputation: 32323
The reason your output isn't the same thing is because you aren't using the formatter to do your printing. The formatter isn't "paired" with the DateTime
, you have to explicitly use it.
Try this:
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
DateTime dt = formatter.parseDateTime("2014-04-24 18:22:01.867");
System.out.println("dt : " + fomatter.print(dt));
Upvotes: 2