ミリ秒が小数点以下3桁の String の date を、
小数点以下2桁の **OffsetDateTime **に変換したいです。
下記のようなコードだとエラーが発生します。
java.time.format.DateTimeParseException: Text '2100-01-02T12:00:00.01Z' could not be parsed: Unable to obtain OffsetDateTime from TemporalAccessor: {InstantSeconds=4102574400},ISO,UTC resolved to 2100-01-02T12:00:00.010 of type java.time.format.Parsed
String dateString = "2100-01-02T12:00:00.011Z";
DateTimeFormatter inFmt = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
.withZone(ZoneId.of("UTC"));
ZonedDateTime date = ZonedDateTime.parse(dateString, inFmt);
DateTimeFormatter outFmt = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SS'Z'")
.withZone(ZoneId.of("UTC"));
return OffsetDateTime.parse(date.format(outFmt), outFmt);
#coding #string #teratail