List of usage examples for org.joda.time DateTime parse
@FromString public static DateTime parse(String str)
From source file:org.flowable.cmmn.engine.impl.behavior.impl.HumanTaskActivityBehavior.java
License:Apache License
protected void handleDueDate(CommandContext commandContext, PlanItemInstanceEntity planItemInstanceEntity, ExpressionManager expressionManager, TaskEntity taskEntity) { if (StringUtils.isNotEmpty(humanTask.getDueDate())) { Object dueDate = expressionManager.createExpression(humanTask.getDueDate()) .getValue(planItemInstanceEntity); if (dueDate != null) { if (dueDate instanceof Date) { taskEntity.setDueDate((Date) dueDate); } else if (dueDate instanceof String) { String dueDateString = (String) dueDate; if (dueDateString.startsWith("P")) { taskEntity.setDueDate( new DateTime(CommandContextUtil.getCmmnEngineConfiguration(commandContext) .getClock().getCurrentTime()).plus(Period.parse(dueDateString)).toDate()); } else { taskEntity.setDueDate(DateTime.parse(dueDateString).toDate()); }/*from www. j a v a2 s .co m*/ } else { throw new FlowableIllegalArgumentException( "Due date expression does not resolve to a Date or Date string: " + humanTask.getDueDate()); } } } }
From source file:org.flowable.cmmn.engine.impl.behavior.impl.TimerEventListenerActivityBehaviour.java
License:Apache License
@Override public void onStateTransition(CommandContext commandContext, DelegatePlanItemInstance planItemInstance, String transition) {/* w ww .java 2 s. c om*/ if (PlanItemTransition.CREATE.equals(transition)) { PlanItemInstanceEntity planItemInstanceEntity = (PlanItemInstanceEntity) planItemInstance; Object timerValue = resolveTimerExpression(commandContext, planItemInstanceEntity); Date timerDueDate = null; boolean isRepeating = false; if (timerValue != null) { if (timerValue instanceof Date) { timerDueDate = (Date) timerValue; } else if (timerValue instanceof DateTime) { DateTime timerDateTime = (DateTime) timerValue; timerDueDate = timerDateTime.toDate(); } else if (timerValue instanceof String) { String timerString = (String) timerValue; BusinessCalendarManager businessCalendarManager = CommandContextUtil .getCmmnEngineConfiguration(commandContext).getBusinessCalendarManager(); if (isDurationString(timerString)) { timerDueDate = businessCalendarManager.getBusinessCalendar(DueDateBusinessCalendar.NAME) .resolveDuedate(timerString); } else if (isRepetitionString(timerString)) { timerDueDate = businessCalendarManager.getBusinessCalendar(CycleBusinessCalendar.NAME) .resolveDuedate(timerString); isRepeating = true; } else { // Try to parse as ISO8601 first try { timerDueDate = DateTime.parse(timerString).toDate(); } catch (Exception e) { } // Try to parse as cron expression try { timerDueDate = businessCalendarManager.getBusinessCalendar(CycleBusinessCalendar.NAME) .resolveDuedate(timerString); isRepeating = true; } catch (Exception pe) { } } } } if (timerDueDate == null) { throw new FlowableException("Timer expression '" + timerExpression + "' did not resolve to java.util.Date, org.joda.time.DateTime, " + "an ISO8601 date/duration/repetition string or a cron expression"); } scheduleTimerJob(commandContext, planItemInstanceEntity, timerValue, timerDueDate, isRepeating); } }
From source file:org.flowable.common.engine.impl.calendar.DueDateBusinessCalendar.java
License:Apache License
@Override public Date resolveDuedate(String duedate, int maxIterations) { try {/*from www. ja va 2s .co m*/ // check if due period was specified if (duedate.startsWith("P")) { return new DateTime(clockReader.getCurrentTime()).plus(Period.parse(duedate)).toDate(); } return DateTime.parse(duedate).toDate(); } catch (Exception e) { throw new FlowableException("couldn't resolve duedate: " + e.getMessage(), e); } }
From source file:org.gradle.performance.fixture.GCEventParser.java
License:Apache License
GCEvent parseLine(String line) { if (line.trim().isEmpty()) { return GCEvent.IGNORED; }// www.jav a2 s.c om Matcher matcher = pattern.matcher(line); if (!matcher.lookingAt()) { if (ignorePattern.matcher(line).matches()) { //I see this kind of events on windows. Let's see if this approach helps resolving them. return GCEvent.IGNORED; } else { notParsed.add(line); return GCEvent.IGNORED; } } try { DateTime timestamp = DateTime.parse(matcher.group(1)); // Some JVMs generate an incorrect timezone offset in the timestamps. Discard timezone and use the local timezone instead timestamp = timestamp.toLocalDateTime().toDateTime(DateTimeZone.getDefault()); long start = Long.parseLong(matcher.group(2)); long end = Long.parseLong(matcher.group(3)); long committed = Long.parseLong(matcher.group(4)); return new GCEvent(start, end, committed, timestamp); } catch (Exception ex) { notParsed.add(line); return GCEvent.IGNORED; } }
From source file:org.gravidence.gravifon.resource.Scrobbles.java
License:Open Source License
/** * Converts raw query param value to datetime. * //from w w w. j a va 2 s . co m * @param paramValue query param value * @param paramName query param name (to specify in error message if any) * @return extracted datetime * @throws ValidationException in case supplied query param value is not <code>null</code> and is not valid datetime */ private DateTime extractDatetimeFromQueryParam(String paramValue, String paramName) throws ValidationException { DateTime result; if (paramValue == null) { result = null; } else { try { result = DateTime.parse(paramValue); } catch (Exception ex) { throw new ValidationException(GravifonError.INVALID, String.format("Query param '%s' is invalid.", paramName)); } } return result; }
From source file:org.graylog.plugins.pipelineprocessor.EvaluationContext.java
License:Open Source License
private EvaluationContext() { this(new Message("__dummy", "__dummy", DateTime.parse("2010-07-30T16:03:25Z"))); // first Graylog release }
From source file:org.graylog2.alerts.AlertServiceImpl.java
License:Open Source License
@Override public AlertCondition fromPersisted(Map<String, Object> fields, Stream stream) throws AbstractAlertCondition.NoSuchAlertConditionTypeException { AbstractAlertCondition.Type type; try {/* www . j a v a 2s .c o m*/ type = AbstractAlertCondition.Type.valueOf(((String) fields.get("type")).toUpperCase()); } catch (IllegalArgumentException e) { throw new AbstractAlertCondition.NoSuchAlertConditionTypeException( "No such alert condition type: [" + fields.get("type") + "]"); } return createAlertCondition(type, stream, (String) fields.get("id"), DateTime.parse((String) fields.get("created_at")), (String) fields.get("creator_user_id"), (Map<String, Object>) fields.get("parameters")); }
From source file:org.graylog2.indexer.ranges.EsIndexRangeService.java
License:Open Source License
private DateTime parseFromDateString(String s) { return DateTime.parse(s); }
From source file:org.graylog2.rest.resources.system.indexer.FailuresResource.java
License:Open Source License
@GET @Timed/* w ww . jav a 2s. c o m*/ @ApiOperation(value = "Total count of failed index operations since the given date.") @ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid date parameter provided.") }) @RequiresPermissions(RestPermissions.INDICES_FAILURES) @Produces(MediaType.APPLICATION_JSON) @Path("count") public FailureCount count( @ApiParam(name = "since", value = "ISO8601 date", required = true) @QueryParam("since") @NotEmpty String since) { final DateTime sinceDate; try { sinceDate = DateTime.parse(since); } catch (IllegalArgumentException e) { final String msg = "Invalid date parameter provided: [" + since + "]"; LOG.error(msg, e); throw new BadRequestException(msg); } return FailureCount.create(indexFailureService.countSince(sinceDate)); }
From source file:org.graylog2.restclient.models.AlarmCallback.java
License:Open Source License
@AssistedInject public AlarmCallback(UserService userService, @Assisted String streamId, @Assisted AlarmCallbackSummaryResponse response) { this.userService = userService; this.streamId = streamId; this.id = response.id; this.type = response.type; this.configuration = response.configuration; this.createdAt = DateTime.parse(response.createdAt); this.creatorUserId = response.creatorUserId; this.creatorUser = userService.load(creatorUserId); }