I am reading data from a file and will need to serialize it out elsewhere after some computation. How can I get the following to print without milliseconds so that the string that is passed to DateTime.parse and what is outputted are identical?
System.out.println(DateTime.parse("2015-06-06T01:51:49-06:00").toString())
2015-06-06T01:51:49.000-06:00
DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(ISODateTimeFormat.dateTimeNoMillis()).toFormatter().withOffsetParsed();
formatter.print(DateTime.parse("2015-06-06T01:51:49-06:00"))
You can use the joda time formatter:
DateTime dt = new DateTime();
DateTimeFormatter fmt = DateTimeFormat.forPattern("MMMM, yyyy");
String str = fmt.print(dt);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With