When creating a new LocalDateTime
using LocalDateTime.now()
on my Mac and Windows machine i get a nano precision of 6 on my Mac an
You can set the precision using a formatter, without resorting to truncatedTo
or Clock.tickMillis
:
jshell> OffsetDateTime.now().format(ISO_DATE_TIME)
$5 ==> "2020-10-21T10:13:48.57776451+02:00"
jshell> OffsetDateTime.now().format(ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSZ"))
$8 ==> "2020-10-21T10:15:31.27+0200"
I realized this after discovering that JDK 15 has different precision on macOS and Linux.