I am trying to format the milliseconds to 3 digit on serialize to ISOString from offsetDate Time
| Value | Expected | Actual |
|---|---|---|
| 2020-06-16T05:47:40.1-06:00 | 2020-06-16T11:47:40.001Z | 2020-06-16T11:47:40.100Z |
| 2020-06-16T05:47:40.12-06:00 | 020-06-16T11:47:40.012Z | 020-06-16T11:47:40.120Z |
When I used
private static final DateTimeFormatter outFormatter = new DateTimeFormatterBuilder()
.parseLenient()
.append(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))
.appendLiteral('.')
.appendValue(ChronoField.MILLI_OF_SECOND,3)
.appendZoneId()
.toFormatter()
.withZone(ZoneId.from(ZoneOffset.UTC));
The documentation says padding will be on Left. But I am getting padding on right.
Any suggestion on how to achieve with date Formatter?