Ejemplo n.º 1
0
 public void test_convertToInstant_furtherAfterLeap() {
   OffsetDateTime odt = OffsetDateTime.of(1980, 1, 1, 0, 0, 1, 0, ZoneOffset.UTC);
   Instant instant = odt.toInstant();
   UtcInstant utc = UtcInstant.ofModifiedJulianDay(MJD_1980, NANOS_PER_SEC);
   assertEquals(rules.convertToInstant(utc), instant);
   assertEquals(rules.convertToUtc(instant), utc);
 }
Ejemplo n.º 2
0
 // -----------------------------------------------------------------------
 // convertToUtc(Instant)/convertToInstant(UtcInstant)
 // -----------------------------------------------------------------------
 public void test_convertToInstant_justBeforeLeap() {
   OffsetDateTime odt = OffsetDateTime.of(1979, 12, 31, 23, 43, 21, 0, ZoneOffset.UTC);
   Instant instant = odt.toInstant();
   UtcInstant utc =
       UtcInstant.ofModifiedJulianDay(MJD_1980 - 1, (SECS_PER_DAY + 1 - 1000) * NANOS_PER_SEC);
   assertEquals(rules.convertToInstant(utc), instant);
   assertEquals(rules.convertToUtc(instant), utc);
 }
Ejemplo n.º 3
0
 public void test_convertToInstant_slsMicros() {
   for (int i = 1; i < 1000; i++) {
     long utcNanos = (SECS_PER_DAY + 1 - 1000) * NANOS_PER_SEC + i * 1000;
     long startSls = (86401 - 1000) * NANOS_PER_SEC;
     long slsNanos = (utcNanos - (utcNanos - startSls) / 1000);
     OffsetDateTime odt =
         OffsetDateTime.of(
             1979, 12, 31, 23, 43, 21, (int) (slsNanos % NANOS_PER_SEC), ZoneOffset.UTC);
     Instant instant = odt.toInstant();
     UtcInstant utc =
         UtcInstant.ofModifiedJulianDay(
             MJD_1980 - 1, (SECS_PER_DAY + 1 - 1000) * NANOS_PER_SEC + i * 1000);
     assertEquals(rules.convertToInstant(utc), instant);
     assertEquals(rules.convertToUtc(instant), utc);
   }
 }
Ejemplo n.º 4
0
 public void test_convertToInstant_slsNanos() {
   for (int i = 1; i < 5005; i++) {
     long utcNanos = (SECS_PER_DAY + 1 - 1000) * NANOS_PER_SEC + i;
     long startSls = (86401 - 1000) * NANOS_PER_SEC;
     long slsNanos = (utcNanos - (utcNanos - startSls) / 1000);
     OffsetDateTime odt =
         OffsetDateTime.of(
             1979, 12, 31, 23, 43, 21, (int) (slsNanos % NANOS_PER_SEC), ZoneOffset.UTC);
     Instant instant = odt.toInstant();
     UtcInstant utc = UtcInstant.ofModifiedJulianDay(MJD_1980 - 1, utcNanos);
     assertEquals(rules.convertToInstant(utc), instant);
     // not all instants can map back to the correct UTC value
     long reverseUtcNanos = startSls + ((slsNanos - startSls) * 1000L) / (1000L - 1);
     assertEquals(
         rules.convertToUtc(instant),
         UtcInstant.ofModifiedJulianDay(MJD_1980 - 1, reverseUtcNanos));
   }
 }