user123475 user123475 - 3 months ago 19x
Java Question

converting Joda time Instant to Java time Instant

I have an instance of Instant (org.joda.time.Instant) which I get in some api response. I have another instance from (java.time.Instant) which I get from some other call. Now, I want to compare these two object to check which one get the latest one. How would it be possible?


getMillis() from joda.time can be compared to toEpochMilli() from java.time.

Class documentation:

Example code.

java.time.Instant myJavaInstant = java.time.Instant.ofEpochMilli( myJodaInstant.getMillis() ) ;

Going the other way.

org.joda.time.Instant myJodaInstant = new org.joda.time.Instant( myJavaInstant.toEpochMilli() ); // Caution: Loss of data if the java.time.Instant has microsecond or nanosecond fraction of second.