I have a problem with Time4J library, I can not convert specific timeStamp to Moment format.
for example, I want something like this: Moment.timeInMillies = myTime
or Moment.of(myTime)
myTime
is a long
value of milliseconds since the epoch, which can be obtained via System.currentTimeMillis()
.
Edit: I think the best conversion is
MILLIS_SINCE_UNIX
can translate betweenLong
andMoment
, so the call implicitly boxes yourlong
.Original answer: I haven’t got the experience, but the way I read the documentation either of the following should work:
Moment.of(myTime / 1000, Math.toIntExact(myTime % 1000 * 1_000_000), TimeScale.POSIX)
Moment.from(Instant.ofEpochMilli(myTime))
I might have missed a more elegant way, though, I don’t know.
Links
TemporalType.MILLIS_SINCE_UNIX
documentationMoment
documentation