@Test(timeout=10000) public void testTimerStartDateISO() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("StartProcess", 1); byte[] content = IoUtils.readBytesFromInputStream(this.getClass().getResourceAsStream("/BPMN2-TimerStartDate.bpmn2")); String processContent = new String(content, "UTF-8"); OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2); processContent = processContent.replaceFirst("#\\{date\\}", plusTwoSeconds.toString()); Resource resource = ResourceFactory.newReaderResource(new StringReader(processContent)); resource.setSourcePath("/BPMN2-TimerStartDate.bpmn2"); resource.setTargetPath("/BPMN2-TimerStartDate.bpmn2"); KieBase kbase = createKnowledgeBaseFromResources(resource); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); final List<Long> list = new ArrayList<Long>(); ksession.addEventListener(new DefaultProcessEventListener() { public void beforeProcessStarted(ProcessStartedEvent event) { list.add(event.getProcessInstance().getId()); } }); assertThat(list.size()).isEqualTo(0); countDownListener.waitTillCompleted(); assertThat(list.size()).isEqualTo(1); }
@Test(timeout=10000) public void testIntermediateCatchEventTimerDateISO() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("timer", 1); 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); }
@Test(timeout=10000) public void testTimerBoundaryEventDateISO() throws Exception { NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("TimerEvent", 1); KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-TimerBoundaryEventDateISO.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.addEventListener(countDownListener); ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler()); HashMap<String, Object> params = new HashMap<String, Object>(); OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2); params.put("date", plusTwoSeconds.toString()); ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent", params); assertProcessInstanceActive(processInstance); countDownListener.waitTillCompleted(); ksession = restoreSession(ksession, true); assertProcessInstanceFinished(processInstance, ksession); }
@Override public String toGraphProperty(OffsetDateTime value) { if (value == null) { return null; } return value.toString(); }
@Override public String toParseableString(OffsetDateTime offsetDateTime) { return offsetDateTime.toString(); } }
@Override public String toParseableString(OffsetDateTime offsetDateTime) { return offsetDateTime.toString(); } }
private JsonObject heartBeatData() { return new JsonObject() .put(GIT_COMMIT_ID, commitId) .put(GIT_REMOTE_URL, remoteUrl) .put(APP_VERSION, appVersion) .put(UP_SINCE, startedAt.toString()) .put(UP_TIME, currentUpTime()); }
/** * Creates a header with a start date. * * @param dateTime The start date. * @return The header. * @see <a href="https://xmpp.org/extensions/xep-0149.html">XEP-0149: Time Periods</a> */ public static Header ofStartDate(OffsetDateTime dateTime) { return new Header("Start", dateTime.toString()); }
/** * Method returns the current dateTime. * * @return String in format yyyy-MM-dd'T'HH:mm:ss.SSSXXX */ public static String getCurrentDateTime() { // final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(OntConfig.DATE_TIME, Locale.ENGLISH); // final Date date = new Date(); return OffsetDateTime.now().toString(); }
@Override public void encode(BsonWriter writer, OffsetDateTime value, EncoderContext encoderContext) { writer.writeString(value.toString()); }
@Override public final String toString() { OffsetDateTime dateTime = getDateTime(); if (dateTime != null) { return dateTime.toString(); } return super.toString(); } }
String dateTimestr = "2015-02-05T02:05:17.000+00:00"; OffsetDateTime dateTime = OffsetDateTime.parse(dateTimestr); if ((dateTime.getNano() == 0) && (dateTimestr.length() > 25 )) System.out.println(dateTime.toLocalDateTime() + ".000Z"); else System.out.println(dateTime.toString());
@Override public String read(String ignored) { return ChronoUnit.MILLIS.addTo(EPOCH, column.nextLong()).toString(); } }
@Override public String read(String ignored) { return ChronoUnit.MICROS.addTo(EPOCH, column.nextLong()).toString(); } }
@Override public Boolean call() { final String sectionName = instanceState.getSectionName(); final StateStorage backend = instanceState.getStorage(); actions.forEach(a -> a.accept(backend, sectionName)); backend.setValue(sectionName, Constants.LAST_UPDATED_KEY.getValue(), DateUtil.offsetNow().toString()); return backend.store(); } }
private void deleteObservations() throws CouldNotPerformException, InterruptedException { //TODO final String dateTimeFrom = StringModifier.convertToLiteral(OffsetDateTime.of(2017, 4, 19, 0, 0, 0, 0, ZoneOffset.UTC).toString(), XsdType.DATE_TIME); final String dateTimeUntil = StringModifier.convertToLiteral(OffsetDateTime.of(2017, 4, 20, 0, 0, 0, 0, ZoneOffset.UTC).toString(), XsdType.DATE_TIME); SparqlHttp.uploadSparqlRequest(QueryExpression.deleteObservationOfTimeFrame(dateTimeFrom, dateTimeUntil), OntConfig.getOntologyDbUrl(), 0); } }
@Override public void toXML(XMLWriter xml) throws IOException { xml.openElement("modifiedby"); xml.attribute("date", this._date.toString()); // TODO date formatting this._member.toXMLAttributes(xml); xml.closeElement(); }
public void setDelinquent(final SessionInfo sessionInfo, final Investment investment) { if (this.isDelinquent(sessionInfo, investment)) { return; } TenantState.of(sessionInfo) .in(DelinquencyTracker.class) .update(b -> b.put(toId(investment), DateUtil.offsetNow().toString())); }
@Override public void toXML(XMLWriter xml) throws IOException { xml.openElement("assignedto"); xml.attribute("date", this._date.toString()); // TODO date formatting this._member.toXMLAttributes(xml); xml.element("fullname", this._member.getFirstname()+" "+this._member.getSurname()); xml.closeElement(); }