I have a timestamp that I receive via a String
in the following format:
2016-10-17T12:42:04.000
I am converting it to a LocalDateTime
to add some days to it (then back to a String
) via the following line:
String _120daysLater = LocalDateTime.parse("2016-10-17T12:42:04.000",
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS")).minusDays(120).toString());
However, I noticed that the response it gives back drops the .000
milliseconds.
I'm not sure the cleanest way to ensure that the exact pattern is preserved. For now I'm just adding a single millisecond, and there's probably a way to incorporate the old SimpleDateFormat
into it, but I was hoping there's an even better way.