Reputation: 41
For example when I am trying to print such OffsetDateTime:
OffsetDateTime offsetDateTime = OffsetDateTime.of(2018, 3, 18, 0, 0, 0, 0, ZoneOffset.UTC);
output is:
2018-03-18T00:00Z
instead of
2018-03-18T00:00:00.000Z
Maybe you know are there any easier way to do it then implement own toString/converter method?
Upvotes: 4
Views: 3832
Reputation: 7081
From Java API: format(DateTimeFormatter formatter) Formats this date-time using the specified formatter.
I would guess the easiest for you would be to use:
OffsetDateTime.of(2018, 3, 18, 0, 0, 0, 0, ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME);
Upvotes: 3