OffsetDateTime to milliseconds
I would just convert the OffsetDateTime
to an Instant
and then use toEpochMilli
:
long millis = book.getInteractionDuration().getStartTimeStamp().toInstant().toEpochMilli();
Unlike toEpochSecond()
, this approach won't lose any more precision than is inherent in wanting milliseconds rather than nanoseconds.
Try this:
long millis = offsetDateTime.toInstant().toEpochMilli();