List of usage examples for org.joda.time Period parse
@FromString public static Period 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()); }/* w w w . j ava2 s . c om*/ } else { throw new FlowableIllegalArgumentException( "Due date expression does not resolve to a Date or Date string: " + humanTask.getDueDate()); } } } }
From source file:org.flowable.common.engine.impl.calendar.DueDateBusinessCalendar.java
License:Apache License
@Override public Date resolveDuedate(String duedate, int maxIterations) { try {//from w w w . j a va 2 s. c o 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.jevis.commons.dataprocessing.Options.java
License:Open Source License
/** * Returns an list of intervals/*from w w w . j ava 2 s . c o m*/ * * @param task * @param from * @param until * @return */ public static List<Interval> getIntervals(Task task, DateTime from, DateTime until) { Period period = Period.days(1); DateTime offset = new DateTime(2001, 01, 01, 00, 00, 00); if (!task.getOptions().containsKey(PERIOD)) { System.out.println("Error missing period option"); } if (!task.getOptions().containsKey(OFFSET)) { System.out.println("Error missing offset option"); task.getOptions().put(OFFSET, "2001-01-01 00:00:00"); } for (Map.Entry<String, String> entry : task.getOptions().entrySet()) { String key = entry.getKey(); String value = entry.getValue(); System.out.println("key: " + key); switch (key) { case PERIOD: System.out.println("period string: " + value); period = Period.parse(value); System.out.println("pared period: " + period); break; case OFFSET: //TODO check value formate DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); offset = dtf.parseDateTime(value); break; } } return buildIntervals(period, offset, from, until); }
From source file:org.jevis.commons.dataprocessing.ProcessOptions.java
License:Open Source License
/** * Returns an list of intervals/*from www. ja v a 2 s. c o m*/ * * @param task * @param from * @param until * @return */ public static List<Interval> getIntervals(Process task, DateTime from, DateTime until) { Period period = Period.days(1); DateTime offset = new DateTime(2001, 01, 01, 00, 00, 00); if (ContainsOption(task, PERIOD)) { System.out.println("Error missing period option"); } if (ContainsOption(task, OFFSET)) { System.out.println("Error missing offset option"); task.getOptions().add(new BasicProcessOption(OFFSET, "2001-01-01 00:00:00")); } for (ProcessOption option : task.getOptions()) { String key = option.getKey(); String value = option.getValue(); System.out.println("key: " + key); switch (key) { case PERIOD: System.out.println("period string: " + value); period = Period.parse(value); System.out.println("pared period: " + period); break; case OFFSET: //TODO check value formate DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); offset = dtf.parseDateTime(value); break; } } return buildIntervals(period, offset, from, until); }
From source file:org.jevis.jeconfig.plugin.object.ObjectTree.java
License:Open Source License
public void fireEventNewFormTable(final JEVisObject parent) throws JEVisException { NewFormTable table = new NewFormTable(); if (parent != null) { if (table.show(JEConfig.getStage(), null, parent, false, NewFormTable.Type.NEW, null) == NewFormTable.Response.YES) { for (int i = 0; i < table.getPairList().size(); i++) { JEVisObject newObject = null; try { if (table.getCreateClass().getName().equals("Data")) { String objectName = table.getPairList().get(i).getKey(); newObject = parent.buildObject(objectName, table.getCreateClass()); newObject.commit(); JEVisAttribute attributeValue = newObject.getAttribute("Value"); if (table.getPairList().get(i).getValue().get(0).isEmpty() && table.getPairList().get(i).getValue().get(1).isEmpty()) { attributeValue.setDisplayUnit(new JEVisUnitImp("", "", JEVisUnit.Prefix.NONE)); } else { String displaySymbol = table.getPairList().get(i).getValue().get(1); JEVisUnit.Prefix prefixDisplayUnit = JEVisUnit.Prefix .valueOf(table.getPairList().get(i).getValue().get(0)); attributeValue.setDisplayUnit( new JEVisUnitImp(Unit.valueOf(displaySymbol), "", prefixDisplayUnit)); }/*ww w . j a v a 2 s.com*/ if (table.getPairList().get(i).getValue().get(3).isEmpty() && table.getPairList().get(i).getValue().get(4).isEmpty()) { attributeValue.setDisplayUnit(new JEVisUnitImp("", "", JEVisUnit.Prefix.NONE)); } else { String inputSymbol = table.getPairList().get(i).getValue().get(4); JEVisUnit.Prefix prefixInputUnit = JEVisUnit.Prefix .valueOf(table.getPairList().get(i).getValue().get(3)); attributeValue.setInputUnit( new JEVisUnitImp(Unit.valueOf(inputSymbol), "", prefixInputUnit)); } if (table.getPairList().get(i).getValue().get(2).isEmpty()) { attributeValue.setDisplaySampleRate(Period.parse("PT0S"));//Period.ZERO } else { String displaySampleRate = table.getPairList().get(i).getValue().get(2); attributeValue.setDisplaySampleRate(Period.parse(displaySampleRate)); } if (table.getPairList().get(i).getValue().get(5).isEmpty()) { attributeValue.setInputSampleRate(Period.parse("PT0S"));//Period.ZERO } else { String inputSampleRate = table.getPairList().get(i).getValue().get(5); attributeValue.setInputSampleRate(Period.parse(inputSampleRate)); } attributeValue.commit(); } else { String objectName = table.getPairList().get(i).getKey(); newObject = parent.buildObject(objectName, table.getCreateClass()); newObject.commit(); List<JEVisAttribute> attribut = newObject.getAttributes(); for (int j = 0; j < attribut.size(); j++) { attribut.get(j) .buildSample(new DateTime(), table.getPairList().get(i).getValue().get(j)) .commit(); } } final TreeItem<JEVisObject> newTreeItem = buildItem(newObject); TreeItem<JEVisObject> parentItem = getObjectTreeItem(parent); parentItem.getChildren().add(newTreeItem); Platform.runLater(new Runnable() { @Override public void run() { getSelectionModel().select(newTreeItem); } }); } catch (JEVisException ex) { Logger.getLogger(ObjectTree.class.getName()).log(Level.SEVERE, null, ex); if (ex.getMessage().equals( "Can not create User with this name. The User has to be unique on the System")) { InfoDialog info = new InfoDialog(); info.show(JEConfig.getStage(), "Waring", "Could not create user", "Could not create new user because this user exists already."); } else { ExceptionDialog errorDia = new ExceptionDialog(); errorDia.show(JEConfig.getStage(), "Error", "Could not create user", "Could not create new user.", ex, JEConfig.PROGRAMM_INFO); } } } } } }
From source file:org.killbill.billing.plugin.adyen.client.AdyenConfigProperties.java
License:Apache License
private Period readPendingExpirationProperty(final Properties properties) { final String valueInDays = properties.getProperty(PROPERTY_PREFIX + "pendingPaymentExpirationPeriodInDays"); if (valueInDays != null) { try {// w ww . j a v a 2 s .c om return Period.days(Integer.parseInt(valueInDays)); } catch (NumberFormatException e) { /* Ignore */ } } final String value = properties.getProperty(PROPERTY_PREFIX + "pendingPaymentExpirationPeriod"); if (value != null) { try { return Period.parse(value); } catch (IllegalArgumentException e) { /* Ignore */ } } return Period.parse(DEFAULT_PENDING_PAYMENT_EXPIRATION_PERIOD); }
From source file:org.killbill.billing.plugin.adyen.client.AdyenConfigProperties.java
License:Apache License
private Period read3DsPendingExpirationProperty(final Properties properties) { final String value = properties.getProperty(PROPERTY_PREFIX + "pending3DsPaymentExpirationPeriod"); if (value != null) { try {//from ww w . j a v a 2s .c o m return Period.parse(value); } catch (IllegalArgumentException e) { /* Ignore */ } } return Period.parse(DEFAULT_PENDING_3DS_PAYMENT_EXPIRATION_PERIOD); }
From source file:org.n52.scidbwcs.md.TemporalReference.java
License:Open Source License
public TemporalReference(String tdim, String t0_str, String dt_str) { this.tdim = tdim; this.t0 = DateTime.parse(t0_str); this.dt = Period.parse(dt_str); }
From source file:org.n52.web.ctrl.DataController.java
License:Open Source License
private void checkAgainstTimespanRestriction(String timespan) { if (requestIntervalRestriction != null) { Duration duration = Period.parse(requestIntervalRestriction).toDurationFrom(new DateTime()); if (duration.getMillis() < Interval.parse(timespan).toDurationMillis()) { throw new BadRequestException("Requested timespan is to long, please use a period shorter than '" + requestIntervalRestriction + "'"); }//from w w w.j a va2s . c om } }
From source file:org.n52.web.ctrl.DataController.java
License:Open Source License
public void setRequestIntervalRestriction(String requestIntervalRestriction) { // validate requestIntervalRestriction, if it's no period an exception occured Period.parse(requestIntervalRestriction); LOGGER.debug("CONFIG: request.interval.restriction={}", requestIntervalRestriction); this.requestIntervalRestriction = requestIntervalRestriction; }