DateTime { public Instant getJavaInstant() { return Instant.ofEpochSecond(utcToJava(utcTime) / 1_000, (utcTime % 10_000_000) * 100); } DateTime();  DateTime(long utcTime);  DateTime(Date date);  DateTime(Instant instant); long getUtcTime(); long getJavaTime(); Date getJavaDate(); Instant getJavaInstant(); boolean isNull(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static DateTime now(); static DateTime nowMillis(); static DateTime nowNanos(); static volatile boolean USE_NANOS; static final DateTime MIN_VALUE; static final DateTime NULL_VALUE; }
@Test public void getJavaInstant() { ZonedDateTime inputZdt = LocalDateTime .of(2020, Month.JANUARY, 10, 20, 30, 40, 123_456_789) .atZone(ZoneId.systemDefault()); Instant endInstant = inputZdt.toInstant(); DateTime dateTime = new DateTime(endInstant); Instant outputInstant = dateTime.getJavaInstant(); ZonedDateTime outputZdt = ZonedDateTime.ofInstant(outputInstant, ZoneId.systemDefault()); assertEquals(outputZdt.getYear(), inputZdt.getYear()); assertEquals(outputZdt.getMonth(), inputZdt.getMonth()); assertEquals(outputZdt.getDayOfMonth(), inputZdt.getDayOfMonth()); assertEquals(outputZdt.getHour(), inputZdt.getHour()); assertEquals(outputZdt.getMinute(), inputZdt.getMinute()); assertEquals(outputZdt.getSecond(), inputZdt.getSecond()); assertEquals(outputZdt.getNano(), 123_456_700); }