Java Code Examples for java.sql.Date#from()

The following examples show how to use java.sql.Date#from() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AttestationCertificateBuilder.java    From webauthn4j with Apache License 2.0 5 votes vote down vote up
public AttestationCertificateBuilder(X509Certificate issuerCertificate, X500Principal subject, PublicKey publicKey) {
    certificateBuilder = new JcaX509v3CertificateBuilder(
            issuerCertificate,
            BigInteger.valueOf(1),
            Date.from(Instant.parse("2000-01-01T00:00:00Z")),
            Date.from(Instant.parse("2999-12-31T23:59:59Z")),
            subject,
            publicKey
    );
}
 
Example 2
Source File: TimestampLogFieldConverter.java    From kafka-connect-spooldir with Apache License 2.0 5 votes vote down vote up
@Override
public void convert(LogEntry logEntry, Struct struct) {
  final LocalDate date = (LocalDate) logEntry.fieldData().get(this.dateField);
  final LocalTime time = (LocalTime) logEntry.fieldData().get(this.timeField);

  final Object value;

  if (null == date || null == time) {
    value = null;
  } else {
    final Instant instant = time.atDate(date).toInstant(ZoneOffset.UTC);
    value = Date.from(instant);
  }
  struct.put(this.field, value);
}
 
Example 3
Source File: CassandraEventPersister.java    From concursus with MIT License 5 votes vote down vote up
private Object[] getBindArguments(Event event) {
    return new Object[] {
            event.getAggregateId().getType(),
            event.getAggregateId().getId(),
            Date.from(event.getEventTimestamp().getTimestamp()),
            event.getEventTimestamp().getStreamId(),
            event.getProcessingId().orElseThrow(() -> new IllegalArgumentException("Event has no processing id")),
            event.getEventName().getName(),
            event.getEventName().getVersion(),
            event.getParameters().serialise(serialiser),
            event.getCharacteristics()
    };
}
 
Example 4
Source File: Debate.java    From kaif with Apache License 2.0 5 votes vote down vote up
public V1DebateDto toV1Dto() {
  return new V1DebateDto(articleId.toString(),
      debateId.toString(),
      zone.value(),
      hasParent() ? parentDebateId.toString() : null,
      level,
      content,
      debaterName,
      upVote,
      downVote,
      Date.from(createTime),
      Date.from(lastUpdateTime));
}
 
Example 5
Source File: Article.java    From kaif with Apache License 2.0 5 votes vote down vote up
public V1ArticleDto toV1Dto() {
  return new V1ArticleDto(zone.value(),
      aliasName,
      articleId.toString(),
      title,
      link,
      content,
      isExternalLink() ? V1ArticleType.EXTERNAL_LINK : V1ArticleType.SPEAK,
      Date.from(createTime),
      authorName,
      upVote,
      debateCount,
      deleted);
}
 
Example 6
Source File: TestJsonReport.java    From sailfish-core with Apache License 2.0 4 votes vote down vote up
private void generateReport(String workFolder) {
    TestScriptDescription testScriptDescription = new TestScriptDescription(
            null,
            Date.from(Instant.now()),
            workFolder,
            "matrix.csv",
            "1..2",
            true,
            "user");

    testScriptDescription.setState(ScriptState.RUNNING);
    testScriptDescription.setStatus(ScriptStatus.NONE);
    testScriptDescription.setContext(getScriptContext());
    testScriptDescription.setLanguageURI(SailfishURI.unsafeParse("plugin:class.name"));

    IScriptReport report = new JsonReport(-1, "report", workspaceDispatcher, testScriptDescription, serviceContext.getDictionaryManager());

    report.createReport(getScriptContext(), "name", "descr", 1, "environment", "user");

    report.createTestCase("someref", "descr", 1, 1, "id", 1, AMLBlockType.TestCase, Collections.emptySet());

    MapMessage message = new MapMessage("namespace", "messageName");
    message.addField("somefield", "somevalue");

    report.createAction(
            "1",
            "service",
            "name",
            "types",
            "descr",
            message,
            null,
            "tag",
            1,
            Arrays.asList("ver1", "ver2"),
            "outcome");

    report.openGroup("groupname", "descr");

    report.createException(new Exception("something happened"));

    report.createLinkToReport("link");

    LoggerRow row = new LoggerRow();
    row.setClazz("someclazz");
    row.setEx(new Exception("exception"));
    row.setLevel(Level.ERROR);
    row.setMessage("somemessage");
    row.setTimestamp(123123123);
    row.setThread("main");

    report.createLogTable(Arrays.asList("column1", "column2"), Collections.singletonList(row));

    report.createMessage(TextColor.BLACK, TextStyle.BOLD, "message");
    report.createMessage(MessageLevel.ERROR, new Exception("exception"), "message");

    report.createParametersTable(message);

    ComparisonResult result = new ComparisonResult("name");

    result.setActual(1);
    result.setExpected(1);

    BugDescription reproduced = new BugDescription("reproduced", "root", "cat1");

    result.setReproducedBugs(Sets.newHashSet(reproduced));

    result.setAllKnownBugs(Sets.newHashSet(
            new BugDescription("subject", "root", "cat1"),
            new BugDescription("subject1", "root"),
            reproduced));

    result.setStatus(StatusType.PASSED);

    result.setMetaData(new MsgMetaData("namespace", "name", Date.from(Instant.now())));

    report.createVerification("name", "description", new StatusDescription(StatusType.NA, "descr"), result);

    report.closeGroup(new StatusDescription(StatusType.NA, "N/A"));

    report.closeAction(new StatusDescription(StatusType.NA, "N/A"), null);

    Map<String, String> map = new HashMap<>();
    map.put("Id", "1");
    map.put("Content", "{\"key\": \"value\"}");
    map.put("ContentJson", "{\"key\": \"value\"}");
    map.put("UnderCheckPoint", "1");
    map.put("RawMessage", "ffffff");
    map.put("From", "SF");
    map.put("To", "SUT");
    map.put("MsgName", "name");
    map.put("Timestamp", "12:00");

    report.createTable(new ReportTable("Messages",
            Arrays.asList("Id", "Content", "ContentJson", "UnderCheckPoint", "RawMessage", "From", "To", "MsgName", "Timestamp"))
            .addRow(map));

    report.closeTestCase(new StatusDescription(StatusType.NA, "N/A"));

    report.closeReport();
}
 
Example 7
Source File: LocalDateLogFieldConverter.java    From kafka-connect-spooldir with Apache License 2.0 4 votes vote down vote up
@Override
protected Object convert(Object input) {
  final LocalDate localDate = (LocalDate) input;
  final Instant instant = localDate.atStartOfDay(ZONE_ID).toInstant();
  return Date.from(instant);
}
 
Example 8
Source File: LocalTimeLogFieldConverter.java    From kafka-connect-spooldir with Apache License 2.0 4 votes vote down vote up
@Override
protected Object convert(Object input) {
  final LocalTime localTime = (LocalTime) input;
  final Instant instant = localTime.atDate(EPOCH_DATE).toInstant(ZoneOffset.UTC);
  return Date.from(instant);
}
 
Example 9
Source File: DebateVoter.java    From kaif with Apache License 2.0 4 votes vote down vote up
public V1VoteDto toV1Dto() {
  return new V1VoteDto(debateId.toString(), voteState, Date.from(updateTime));
}
 
Example 10
Source File: ArticleVoter.java    From kaif with Apache License 2.0 4 votes vote down vote up
public V1VoteDto toV1Dto() {
  return new V1VoteDto(articleId.toString(), voteState, Date.from(updateTime));
}