Example usage for java.time OffsetDateTime toString

List of usage examples for java.time OffsetDateTime toString

Introduction

In this page you can find the example usage for java.time OffsetDateTime toString.

Prototype

@Override
public String toString() 

Source Link

Document

Outputs this date-time as a String , such as 2007-12-03T10:15:30+01:00 .

Usage

From source file:org.jbpm.bpmn2.IntermediateEventTest.java

@Test(timeout = 10000)
public void testIntermediateCatchEventTimerDateISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer",
            1);/*from ww  w  .ja  va  2 s . c o  m*/

    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-IntermediateCatchEventTimerDateISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new DoNothingWorkItemHandler());
    ksession.addEventListener(countDownListener);

    HashMap<String, Object> params = new HashMap<String, Object>();
    OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
    params.put("date", plusTwoSeconds.toString());
    ProcessInstance processInstance = ksession.startProcess("IntermediateCatchEvent", params);
    assertProcessInstanceActive(processInstance);
    // now wait for 1 second for timer to trigger
    countDownListener.waitTillCompleted();

    assertProcessInstanceFinished(processInstance, ksession);

}

From source file:org.matonto.catalog.impl.SimpleCatalogManager.java

@Override
public Commit createCommit(@Nonnull InProgressCommit inProgressCommit, Set<Commit> parents,
        @Nonnull String message) {
    IRI associatedWith = vf.createIRI(Activity.wasAssociatedWith_IRI);
    IRI informedBy = vf.createIRI(Activity.wasInformedBy_IRI);
    OffsetDateTime now = OffsetDateTime.now();
    Value user = inProgressCommit.getProperty(associatedWith).get();
    String metadata = now.toString() + user.stringValue();
    IRI generatedIRI = vf.createIRI(Activity.generated_IRI);

    if (parents != null) {
        metadata += parents.stream()/*from   ww  w  .j a v a 2s  .c o  m*/
                .sorted(Comparator.comparing(commit2 -> commit2.getResource().stringValue()))
                .map(commit -> commit.getResource().stringValue()).collect(Collectors.joining(""));
    }

    Commit commit = commitFactory.createNew(vf.createIRI(COMMIT_NAMESPACE + DigestUtils.shaHex(metadata)));
    commit.setProperty(inProgressCommit.getProperty(generatedIRI).get(), generatedIRI);
    commit.setProperty(vf.createLiteral(now), vf.createIRI(PROV_AT_TIME));
    commit.setProperty(vf.createLiteral(message), vf.createIRI(DCTERMS.TITLE.stringValue()));
    commit.setProperty(user, associatedWith);

    Model revisionModel = mf.createModel(inProgressCommit.getModel());
    revisionModel.remove(inProgressCommit.getResource(), null, null);
    Revision revision = revisionFactory.getExisting((Resource) inProgressCommit.getProperty(generatedIRI).get(),
            revisionModel);

    if (parents != null) {
        revision.setProperties(parents.stream().map(parent -> parent.getProperty(generatedIRI).get())
                .collect(Collectors.toSet()), vf.createIRI(Entity.wasDerivedFrom_IRI));
        commit.setProperties(parents.stream().map(Commit::getResource).collect(Collectors.toSet()), informedBy);
    }

    commit.getModel().addAll(revisionModel);
    return commit;
}