我有一个Instant (org.joda.time.Instant)的实例,我在一些api响应中得到了它。我有另一个来自(java.time.Instant)的实例,它是从其他调用中获得的。现在,我想要比较这两个对象,以检查哪个对象获得了最新的对象。这怎么可能呢?
发布于 2016-07-23 01:46:21
可以将来自joda.time的getMillis()与来自java.time的toEpochMilli()进行比较。
类文档:
示例代码。
java.time.Instant myJavaInstant =
java.time.Instant.ofEpochMilli( myJodaInstant.getMillis() ) ;走另一条路。
// Caution: Loss of data if the java.time.Instant has microsecond
// or nanosecond fraction of second.
org.joda.time.Instant myJodaInstant =
new org.joda.time.Instant( myJavaInstant.toEpochMilli() ); 发布于 2018-04-18 20:08:15
您可以将joda Instant转换为java的(日期时间和格式只是一个示例):
org.joda.time.Instant.parse("10.02.2017 13:45:32", DateTimeFormat.forPattern("dd.MM.yyyy HH:mm:ss")).toDate().toInstant()因此,您可以在joda Instant上调用toDate()和toInstant()。
https://stackoverflow.com/questions/38532361
复制相似问题