@Test
  public void
      number_of_booking_during_time_period_returns_1_if_queried_with_end_date_in_the_middle_of_an_existing_booking() {
    LocalDate booking_from = LocalDate.of(2015, 7, 1);

    LocalDate booking_to = LocalDate.of(2015, 7, 18);

    LocalDate query_from = LocalDate.of(2015, 6, 12);
    LocalDate query_to = LocalDate.of(2015, 7, 12);

    Date from_date =
        Date.from(booking_from.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    Date to_date = Date.from(booking_to.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    Booking booking1 =
        Booking.builder()
            .apartment(apartment)
            .customer(customer)
            .startDate(from_date)
            .endDate(to_date)
            .build();

    repository.save(booking1);

    Date query_from_date =
        Date.from(query_from.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    Date query_to_date =
        Date.from(query_to.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());

    assertThat(
        repository.findNumberOfBookingDuringTimePeriod(apartment, query_from_date, query_to_date),
        is(1));
  }
 @Override
 public Date convert(Object value) {
   Date converted = super.convert(value);
   if (converted == null) {
     if (value instanceof LocalDateTime) {
       converted = Date.from(((LocalDateTime) value).atZone(ZoneId.systemDefault()).toInstant());
     } else if (value instanceof LocalDate) {
       converted = Date.from(((LocalDate) value).atStartOfDay(ZoneId.systemDefault()).toInstant());
     }
   }
   return converted;
 }
 @Override
 public void onApplicationEvent(BeforeConvertEvent<Object> event) {
   Object obj = event.getSource();
   Instant utcInstantTime = ZonedDateTime.now(ZoneOffset.UTC).toInstant();
   if (AuditorModel.class.isAssignableFrom(obj.getClass())) {
     AuditorModel entity = (AuditorModel) obj;
     if (entity.isNew()) {
       entity.setCreatedDate(Date.from(utcInstantTime));
       entity.setLastModifiedDate(Date.from(utcInstantTime));
     } else {
       entity.setLastModifiedDate(Date.from(utcInstantTime));
     }
   }
 }
Exemplo n.º 4
0
 void storeTimestampOfLastExport(ODocument workItem) {
   store.setFields(
       workItem, //
       of(
           FieldNames.JIRA_EXPORT_TIMESTAMP,
           StorageQuery.getField(workItem, FieldNames.MODIFIED, Date.from(Instant.now()))));
 }
Exemplo n.º 5
0
  @Test
  public void testCookieBuilder() {
    // given
    LocalDateTime now = LocalDateTime.now();

    // when
    Cookie cookie =
        CookieBuilder.create()
            .name("foo")
            .value("bar")
            .path("/foobar")
            .domain("www.foo.com")
            .maxAge(1223)
            .expires(now)
            .discard(true)
            .secure(true)
            .httpOnly(true)
            .build();

    // then
    assertThat(cookie, not(nullValue()));
    assertThat("foo", equalTo(cookie.getName()));
    assertThat("bar", equalTo(cookie.getValue()));
    assertThat("/foobar", equalTo(cookie.getPath()));
    assertThat("www.foo.com", equalTo(cookie.getDomain()));
    assertThat(
        Date.from(now.atZone(ZoneId.systemDefault()).toInstant()), equalTo(cookie.getExpires()));
    assertThat(cookie.getMaxAge(), equalTo(1223));
    assertThat(cookie.isDiscard(), equalTo(true));
    assertThat(cookie.isSecure(), equalTo(true));
    assertThat(cookie.isHttpOnly(), equalTo(true));
  }
  @Test
  public void testSigning()
      throws IOException, URISyntaxException, StorageException, InvalidKeyException {
    CloudBlobContainer container = binaryManager.container;
    Binary binary = binaryManager.getBinary(Blobs.createBlob(CONTENT));
    assertNotNull(binary);

    CloudBlockBlob blockBlobReference = container.getBlockBlobReference(CONTENT_MD5);
    SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy();
    policy.setPermissionsFromString("r");

    // rscd content-dispositoon
    // rsct content-type

    Instant endDateTime =
        LocalDateTime.now().plusHours(1).atZone(ZoneId.systemDefault()).toInstant();
    policy.setSharedAccessExpiryTime(Date.from(endDateTime));

    SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders();
    headers.setContentDisposition("attachment; filename=\"blabla.txt\"");
    headers.setContentType("text/plain");

    String something = blockBlobReference.generateSharedAccessSignature(policy, headers, null);
    System.out.println(something);

    CloudBlockBlob blob =
        new CloudBlockBlob(
            blockBlobReference.getUri(), new StorageCredentialsSharedAccessSignature(something));

    System.out.println(blob.getQualifiedUri());
  }
 @Test
 public void testFindByUserIdAndExpireOnGreaterThan() {
   AccessToken accessToken =
       accessTokenRepository.findByUserIdAndExpiresOnGreaterThan(
           1L, Date.from(LocalDateTime.of(2015, 1, 1, 0, 0).toInstant(ZoneOffset.UTC)));
   assertThat(accessToken, is(notNullValue()));
   assertNotNull(accessToken.getUser().getId());
 }
 public PasswordResetToken newPasswordResetToken(User user, boolean expired) {
   PasswordResetToken passwordResetToken = newPasswordResetToken(user);
   if (expired) {
     Date now = Date.from(Calendar.getInstance().toInstant());
     passwordResetToken.setExpiryDate(now);
   }
   return passwordResetToken;
 }
Exemplo n.º 9
0
 @Test
 public void createValidThing() throws Exception {
   Thing thing = new Thing();
   thing.setName("simon");
   thing.setAmount(6);
   thing.setDueDate(Date.from(Instant.now().plus(1, ChronoUnit.DAYS)));
   thing.setTags(Collections.singletonList("super"));
   thingManager.create(thing);
 }
Exemplo n.º 10
0
 /**
  * Convert a PersistentAuditEvent to an AuditEvent
  *
  * @param persistentEvent the persistentEvent to convert
  * @return the converted list.
  */
 public AuditEvent convertToAuditEvent(PersistentAuditEvent persistentEvent) {
   Instant instant =
       persistentEvent.getAuditEventDate().atZone(ZoneId.systemDefault()).toInstant();
   return new AuditEvent(
       Date.from(instant),
       persistentEvent.getPrincipal(),
       persistentEvent.getAuditEventType(),
       convertDataToObjects(persistentEvent.getData()));
 }
Exemplo n.º 11
0
 @Override
 public void createOrUpdateItem(ODocument item) throws Exception {
   String workItemId = item.field(FieldNames.ID);
   ensureWorkItemWithId(Integer.parseInt(workItemId));
   Date modified = StorageQuery.getField(item, FieldNames.MODIFIED, Date.from(Instant.now()));
   Date lastExport = StorageQuery.getField(item, FieldNames.JIRA_EXPORT_TIMESTAMP, new Date(0));
   if (modified.compareTo(lastExport) > 0) {
     updateItem(item);
   }
 }
 @Override
 public void nullSafeSet(
     PreparedStatement preparedStatement, Object value, int index, SessionImplementor session)
     throws HibernateException, SQLException {
   if (value == null) {
     StandardBasicTypes.DATE.nullSafeSet(preparedStatement, null, index, session);
   } else {
     LocalDate ld = ((LocalDate) value);
     Instant instant = ld.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
     Date time = Date.from(instant);
     StandardBasicTypes.DATE.nullSafeSet(preparedStatement, time, index, session);
   }
 }
Exemplo n.º 13
0
  public static void main(String... args) {
    F<String, F<String, Date>> simpleDate =
        df ->
            s -> {
              try {
                return new SimpleDateFormat(df).parse(s);
              } catch (Exception e) {
                throw new RuntimeException(e);
              }
            };

    Either<String, Date> res =
        parseDate(
            Either.left(args[0]),
            s -> Date.from(LocalDateTime.parse(s).toInstant(ZoneOffset.UTC)),
            s -> Date.from(OffsetDateTime.parse(s).toInstant()),
            s -> Date.from(ZonedDateTime.parse(s).toInstant()),
            simpleDate.f("yyyy-MM-dd HH:mm:ss"),
            s -> "now".equals(s) ? new Date() : null);

    System.out.println("------");

    System.out.println(res);
  }
  @Test
  public void testUpdate() throws Exception {

    logger.debug("\nSTARTED testUpdate()\n");
    final String NEW_NOTE = "Update AllagamentiOsserv notes test";

    Result<List<AllagamentiOsserv>> list = allagamentiOsservService.findAll(TEST_USER_ID);
    AllagamentiOsserv a = list.getData().get(0);
    // c.setCompanyName(NEW_NAME);

    allagamentiOsservService.store(
        a.getIdAllagamentoOsserv(),
        a.getIndirizzo(),
        Date.from(Instant.now()),
        Date.from(Instant.now()),
        74001,
        1,
        1,
        1,
        NEW_NOTE,
        //                TEST_USER_ID,
        //                Date.from(Instant.now()),
        //                TEST_USER_ID,
        //                Date.from(Instant.now()),
        1,
        12.457256,
        41.902232,
        TEST_USER_ID);

    Result<AllagamentiOsserv> list2 =
        allagamentiOsservService.find(a.getIdAllagamentoOsserv(), TEST_USER_ID);

    assertTrue(list2.getData().getNoteAllagamento().equals(NEW_NOTE));

    logger.debug("\nFINISHED testUpdate()\n");
  }
Exemplo n.º 15
0
  @Test
  public void node_index_document_meta_data_values() throws Exception {
    final String myAnalyzerName = "myAnalyzer";

    Instant modifiedDateTime = LocalDateTime.of(2013, 1, 2, 3, 4, 5).toInstant(ZoneOffset.UTC);

    Node node =
        Node.newNode()
            .id(EntityId.from("myId"))
            .parent(NodePath.ROOT)
            .name(NodeName.from("my-name"))
            .createdTime(Instant.now())
            .creator(UserKey.from("test:creator"))
            .modifier(UserKey.from("test:modifier").asUser())
            .modifiedTime(modifiedDateTime)
            .entityIndexConfig(
                EntityPropertyIndexConfig.newEntityIndexConfig().analyzer(myAnalyzerName).build())
            .build();

    final Collection<IndexDocument> indexDocuments =
        NodeIndexDocumentFactory.create(node, TEST_WORKSPACE);

    final IndexDocument indexDocument = getIndexDocumentOfType(indexDocuments, IndexType.NODE);

    assertEquals(myAnalyzerName, indexDocument.getAnalyzer());
    assertEquals(TEST_WORKSPACE.getSearchIndexName(), indexDocument.getIndexName());
    assertEquals(IndexType.NODE.getName(), indexDocument.getIndexTypeName());

    final AbstractIndexDocumentItem createdTimeItem =
        getItemWithName(
            indexDocument, NodeIndexDocumentFactory.CREATED_TIME_PROPERTY, IndexValueType.DATETIME);

    assertEquals(Date.from(node.getCreatedTime()), createdTimeItem.getValue());

    final AbstractIndexDocumentItem creator =
        getItemWithName(
            indexDocument, NodeIndexDocumentFactory.CREATOR_PROPERTY_PATH, IndexValueType.STRING);

    assertEquals("test:creator", creator.getValue());

    final AbstractIndexDocumentItem modifier =
        getItemWithName(
            indexDocument, NodeIndexDocumentFactory.MODIFIER_PROPERTY_PATH, IndexValueType.STRING);

    assertEquals("test:modifier", modifier.getValue());
  }
Exemplo n.º 16
0
  @Override
  protected ExitStatus doRead(
      StepContribution contribution, ExecutionContext context, ExcelRow item) {
    ExitStatus result = ExitStatus.EXECUTING;
    LocalDate thresholdDate = getMaxMonthsThresholdDate(item);

    if (thresholdDate != null) {
      // We store the threshold date in the context
      context.put(
          "threshold.date",
          Date.from(thresholdDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()));
      // We keep trace that we've stored something
      contribution.incrementWriteCount(1);
      result = COMPLETED_WITH_MAX_MONTHS;
    }

    return result;
  }
/**
 * @author Artur Janeczko
 * @since 0.0.1
 */
public class TimestampAnalysisInputDataVOTest {

  private static final String TC_STRING = "tcString";
  private static final Function<TestClass, String> FUNCTION = TestClass::getS;
  private static final Date DATE = Date.from(Instant.now());

  //    @Test
  //    public void shouldProperlyBuildInput() {
  //        // given
  //        TestClass tc = new TestClass();
  //        tc.setS(TC_STRING);
  //        Collection<TestClass> collection = Lists.newArrayList(tc);
  //        Map<Long, Date> dates = Maps.newHashMap();
  //        dates.put(0L, DATE);
  //        // when
  //        TimestampAnalysisInputDataVO vo = TimestampAnalysisInputDataVO.Builder
  //                .getInstance()
  //                .collection(collection)
  //                .function(FUNCTION)
  //                .withDates(dates)
  //                .build();
  //        // then
  //        assertThat(vo.getData()).hasSize(1);
  //        TestClass first = Iterables.getFirst(vo.getData(), null);
  //        assertThat(first.getS()).isEqualTo(TC_STRING);
  //        assertThat(vo.getFunction()).isEqualTo(FUNCTION);
  //        assertThat(vo.getDates()).hasSize(1);
  //        assertThat(vo.getDates().get(0L)).isEqualTo(DATE);
  //    }

  private final class TestClass {

    private String s;

    public String getS() {
      return s;
    }

    public void setS(final String s) {
      this.s = s;
    }
  }
}
Exemplo n.º 18
0
  private void createScreenShotButton() {
    screenShotButton = new Button(FontAwesome.ICON_CAMERA);
    screenShotButton.setFont(Font.font("FontAwesome", 14));
    screenShotButton.setTooltip(new Tooltip("Take Screen Shot."));
    //        screenShotButton.disableProperty().bind(webEngine.getLoadWorker().runningProperty());
    screenShotButton.setOnAction(
        observable -> {
          WritableImage image = masterPane.snapshot(null, null);
          SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss'.png'");

          FileChooser fileChooser = new FileChooser();
          fileChooser.setTitle("Save Screen Shot...");
          fileChooser.setInitialFileName(simpleDateFormat.format(Date.from(Instant.now())));
          File imageFile = fileChooser.showSaveDialog(null);

          if (imageFile != null) {
            try {
              ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", imageFile);
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });
  }
Exemplo n.º 19
0
 private Date toDate(final LocalDate localDate) {
   final Instant instant = localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant();
   return Date.from(instant);
 }
 @Override
 public Date convertToDatabaseColumn(LocalDateTime localDateTime) {
   Instant from = Instant.from(localDateTime);
   return Date.from(from);
 }
  @Override
  public TroubleReportTemplate deserialize(
      JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    JsonNode jsonNode = jsonParser.getCodec().readTree(jsonParser);
    JsonNode troubleReportTemplate = jsonNode.get("troubleReportTemplate");

    ServiceProblemId serviceProblemId =
        new ServiceProblemId(troubleReportTemplate.get("serviceProblemId").asLong());
    String troubleReportId = troubleReportTemplate.get("troubleReportId").asText();
    String appointmentReference = troubleReportTemplate.get("appointmentReference").asText();
    boolean twentyFourHourAccess = troubleReportTemplate.get("twentyFourHourAccess").asBoolean();
    String earliestAccessDate =
        troubleReportTemplate.get("earliestAccessDate").asText().equals("null")
            ? null
            : troubleReportTemplate.get("earliestAccessDate").asText();
    String latestAccessDate =
        troubleReportTemplate.get("latestAccessDate").asText().equals("null")
            ? null
            : troubleReportTemplate.get("latestAccessDate").asText();
    String serviceTypeCode = troubleReportTemplate.get("serviceType").get("code").asText();
    SnsServiceId serviceId = new SnsServiceId(troubleReportTemplate.get("serviceId").asLong());
    String providerReference = troubleReportTemplate.get("providerReference").asText();
    String btReference = troubleReportTemplate.get("btReference").asText();
    String description = troubleReportTemplate.get("description").asText();
    String accessHazards = troubleReportTemplate.get("accessHazards").asText();
    String accessNotes = troubleReportTemplate.get("accessNotes").asText();
    String contactName = troubleReportTemplate.get("contactName").asText();
    String contactNumber = troubleReportTemplate.get("contactNumber").asText();
    String secondaryContactName = troubleReportTemplate.get("secondaryContactName").asText();
    String secondaryContactNumber = troubleReportTemplate.get("secondaryContactNumber").asText();
    String notes = troubleReportTemplate.get("notes").asText();
    String temporaryCallDiversionNumber =
        troubleReportTemplate.get("temporaryCallDiversionNumber").asText();
    int upperTrcBand = troubleReportTemplate.get("upperTrcBand").asInt();
    boolean cancelRequested = troubleReportTemplate.get("cancelRequested").asBoolean();
    boolean amendRequested = troubleReportTemplate.get("amendRequested").asBoolean();
    boolean confirmEquipmentDisconnectedRequested =
        troubleReportTemplate.get("confirmEquipmentDisconnectedRequested").asBoolean();
    boolean broadbandFault = troubleReportTemplate.get("broadbandFault").asBoolean();
    boolean coopCallRequested = troubleReportTemplate.get("coopCallRequested").asBoolean();
    boolean disRequested = troubleReportTemplate.get("disRequested").asBoolean();
    boolean isResponseRequired = troubleReportTemplate.get("isResponseRequired").asBoolean();
    boolean intermittentProblem = troubleReportTemplate.get("intermittentProblem").asBoolean();
    JsonNode symptomNode = troubleReportTemplate.get("symptom");
    TroubleReportSymptomDTO symptom =
        new TroubleReportSymptomDTO(
            symptomNode.get("symptomCode").asText(),
            symptomNode.get("providerCode").asText(),
            symptomNode.get("description").asText(),
            symptomNode.get("mapsToNetworkFeature").asBoolean(),
            symptomNode.get("mapToNetworkFeatureName").asText(),
            symptomNode.get("mapToNetworkFeaturePin").asText());
    JsonNode lineTestSummaryNode = troubleReportTemplate.get("lineTestSummary");
    LineTestSummaryDTO lineTestSummary =
        new LineTestSummaryDTO(
            lineTestSummaryNode.get("lineTestReference").asText(),
            lineTestSummaryNode.get("performerReference").asText(),
            lineTestSummaryNode.get("mainFaultLocation").asText(),
            lineTestSummaryNode.get("isCompleted").asBoolean(),
            lineTestSummaryNode.get("faultReportAdvised").asBoolean(),
            lineTestSummaryNode.get("requiresAppointment").asBoolean());

    StructuredQuestionCode structuredQuestionCode = null;
    if (troubleReportTemplate.hasNonNull("structuredQuestionCode")) {
      structuredQuestionCode =
          StructuredQuestionCode.valueOf(
              troubleReportTemplate.get("structuredQuestionCode").asText());
    }

    TroubleReportStatus troubleReportStatus = TroubleReportStatus.New;
    if (troubleReportTemplate.hasNonNull("status")) {
      troubleReportStatus =
          TroubleReportStatus.valueOf(troubleReportTemplate.get("status").asText());
    }

    TestProduct testProduct = null;
    if (troubleReportTemplate.hasNonNull("testProduct")) {
      testProduct = TestProduct.valueOf(troubleReportTemplate.get("testProduct").asText());
    }

    return new TroubleReportTemplateBuilder()
        .with(serviceProblemId)
        .withTwentyFourHourAccess(twentyFourHourAccess)
        .withEarliestAccessDate(new Date())
        .withAppointmentReference(appointmentReference)
        .withEarliestAccessDate(
            earliestAccessDate != null
                ? Date.from(ZonedDateTime.parse(earliestAccessDate).toInstant())
                : null)
        .withLatestAccessDate(
            latestAccessDate != null
                ? Date.from(ZonedDateTime.parse(latestAccessDate).toInstant())
                : null)
        .withServiceType(ServiceType.valueOf(serviceTypeCode))
        .with(serviceId)
        .withProviderReference(providerReference)
        .withBtReference(btReference)
        .withDescription(description)
        .withAccessHazards(accessHazards)
        .withAccessNotes(accessNotes)
        .withContactName(contactName)
        .withContactNumber(contactNumber)
        .withSecondaryContactName(secondaryContactName)
        .withSecondaryContactNumber(secondaryContactNumber)
        .withNotes(notes)
        .withTemporaryCallDiversionNumber(temporaryCallDiversionNumber)
        .withCancelRequested(cancelRequested)
        .withAmendRequested(amendRequested)
        .withConfirmEquipmentDisconnectedRequested(confirmEquipmentDisconnectedRequested)
        .withBroadbandFault(broadbandFault)
        .withCoopCallRequested(coopCallRequested)
        .withDisRequested(disRequested)
        .withIsResponseRequired(isResponseRequired)
        .withIntermittentProblem(intermittentProblem)
        .withSymptom(symptom)
        .withLineTestSummary(lineTestSummary)
        .withUpperTrcBand(troubleReportTemplate.get("upperTrcBand").asInt())
        .withTestProduct(testProduct)
        .withStructuredQuestionCode(structuredQuestionCode)
        .withStatus(troubleReportStatus)
        .withTroubleReportId(new TroubleReportId(troubleReportId))
        .withUpperTrcBand(upperTrcBand)
        .build();
  }
Exemplo n.º 22
0
 @Override
 public Date convert(LocalDate value) {
   return Date.from(value.atStartOfDay(ZoneOffset.UTC).toInstant());
 }
 /**
  * Given an expire date for a link and the previous days for the alert to be sent, calculates the
  * date in which the alert will be sent. Since the user does not specify a time, it is set to
  * 00:00.
  */
 protected Date processAlertDate(String expireDate, String days) {
   DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
   LocalDate expireLocal = LocalDate.parse(expireDate, formatter);
   LocalDate alertLocal = expireLocal.minusDays(Long.parseLong(days));
   return Date.from(alertLocal.atStartOfDay(ZoneId.systemDefault()).toInstant());
 }
 @Override
 public Date convert(LocalDateTime source) {
   return source == null ? null : Date.from(source.atZone(ZoneId.systemDefault()).toInstant());
 }
Exemplo n.º 25
0
 public Date getDate(LocalDate localDate) {
   return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
 }
 @Override
 public Date convert(ZonedDateTime source) {
   return source == null ? null : Date.from(source.toInstant());
 }
 /**
  * Builds a Trigger which fires the Job identified by {@code jobKey} at (or around) the given
  * {@code triggerDateTime}.
  *
  * @param triggerDateTime The time at which a trigger was requested
  * @param jobKey The key of the job to be triggered
  * @return a configured Trigger for the Job with key {@code jobKey}
  */
 protected Trigger buildTrigger(Instant triggerDateTime, JobKey jobKey) {
   return TriggerBuilder.newTrigger().forJob(jobKey).startAt(Date.from(triggerDateTime)).build();
 }
Exemplo n.º 28
0
 public static Date fromLocalDateIn(LocalDate date, ZoneOffset timeZone) {
   return Date.from(date.atStartOfDay().toInstant(timeZone));
 }
Exemplo n.º 29
0
 public static Date fromLocalDateInUTC(LocalDate date) {
   return Date.from(date.atStartOfDay().toInstant(ZoneOffset.UTC));
 }
Exemplo n.º 30
0
  public static void main(String[] args) throws Throwable {

    int N = 10000;
    long t1970 = new java.util.Date(70, 0, 01).getTime();
    Random r = new Random();
    for (int i = 0; i < N; i++) {
      int days = r.nextInt(50) * 365 + r.nextInt(365);
      long secs = t1970 + days * 86400 + r.nextInt(86400);
      int nanos = r.nextInt(NANOS_PER_SECOND);
      int nanos_ms = nanos / 1000000 * 1000000; // millis precision
      long millis = secs * 1000 + r.nextInt(1000);
      LocalDateTime ldt = LocalDateTime.ofEpochSecond(secs, nanos, ZoneOffset.UTC);
      LocalDateTime ldt_ms = LocalDateTime.ofEpochSecond(secs, nanos_ms, ZoneOffset.UTC);
      Instant inst = Instant.ofEpochSecond(secs, nanos);
      Instant inst_ms = Instant.ofEpochSecond(secs, nanos_ms);
      ///////////// java.util.Date /////////////////////////
      Date jud = new java.util.Date(millis);
      Instant inst0 = jud.toInstant();
      if (jud.getTime() != inst0.toEpochMilli() || !jud.equals(Date.from(inst0))) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: j.u.d -> instant -> j.u.d");
      }
      // roundtrip only with millis precision
      Date jud0 = Date.from(inst_ms);
      if (jud0.getTime() != inst_ms.toEpochMilli() || !inst_ms.equals(jud0.toInstant())) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: instant -> j.u.d -> instant");
      }
      //////////// java.util.GregorianCalendar /////////////
      GregorianCalendar cal = new GregorianCalendar();
      // non-roundtrip of tz name between j.u.tz and j.t.zid
      cal.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()));
      cal.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
      cal.setFirstDayOfWeek(Calendar.MONDAY);
      cal.setMinimalDaysInFirstWeek(4);
      cal.setTimeInMillis(millis);
      ZonedDateTime zdt0 = cal.toZonedDateTime();
      if (cal.getTimeInMillis() != zdt0.toInstant().toEpochMilli()
          || !cal.equals(GregorianCalendar.from(zdt0))) {
        System.out.println("cal:" + cal);
        System.out.println("zdt:" + zdt0);
        System.out.println("calNew:" + GregorianCalendar.from(zdt0));
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: gcal -> zdt -> gcal");
      }
      inst0 = cal.toInstant();
      if (cal.getTimeInMillis() != inst0.toEpochMilli()) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: gcal -> zdt");
      }
      ZonedDateTime zdt = ZonedDateTime.of(ldt_ms, ZoneId.systemDefault());
      GregorianCalendar cal0 = GregorianCalendar.from(zdt);
      if (zdt.toInstant().toEpochMilli() != cal0.getTimeInMillis()
          || !zdt.equals(GregorianCalendar.from(zdt).toZonedDateTime())) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: zdt -> gcal -> zdt");
      }
    }

    ///////////// java.util.TimeZone /////////////////////////
    for (String zidStr : TimeZone.getAvailableIDs()) {
      // TBD: tzdt intergration
      if (zidStr.startsWith("SystemV")
          || zidStr.contains("Riyadh8")
          || zidStr.equals("US/Pacific-New")
          || zidStr.equals("EST")
          || zidStr.equals("HST")
          || zidStr.equals("MST")) {
        continue;
      }
      ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS);
      if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) {
        throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr);
      }
      TimeZone tz = TimeZone.getTimeZone(zidStr);
      // no round-trip for alias and "GMT"
      if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId()))
          && !ZoneId.SHORT_IDS.containsKey(zidStr)
          && !zidStr.startsWith("GMT")) {
        throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr);
      }
    }
    System.out.println("Passed!");
  }