I have a date that I want to change into a different format.
Current format: Fri Apr 07 08:21:19 MDT 2017
Desired format: 2017-04-07T13:28:41.00MDT
. I want to have the desired format output as a string.
I am currently doing this:
DateTimeFormatter sourceFormat = DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss z uuuu");
ZonedDateTime dateParsed = ZonedDateTime.parse(dateStr, sourceFormat);
String fullDateTimeStr = fullDateTime.format(dateParsed);
The formatting is correct, but the main issue I'm having is preserving the fractional seconds (the two numbers right before the time zone.) I know that the date I am receiving has the ms/fractional seconds preserved because when I print out long epoch = ((Date) date).getTime();
I get the epoch time and I can convert it (using an online conversion tool) and it shows the correct date/time with ms.
What's going on?