List of usage examples for org.joda.time.format ISODateTimeFormat dateTime
public static DateTimeFormatter dateTime()
From source file:com.amazonaws.services.dynamodbv2.datamodeling.unmarshallers.DynamoDBUnmarshallerUtil.java
License:Apache License
public static SSUnmarshaller getDateTimeSSUnmarshaller() { return new SSUnmarshaller() { private final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime(); @Override//from ww w .ja v a 2 s .c o m public Object unmarshall(final AttributeValue value) throws ParseException { final Set<DateTime> argument = new HashSet<DateTime>(); for (final String s : value.getSS()) { argument.add(dateTimeFormatter.parseDateTime(s)); } return argument; } }; }
From source file:com.amazonaws.services.dynamodbv2.datamodeling.unmarshallers.DynamoDBUnmarshallerUtil.java
License:Apache License
public static SUnmarshaller getDateTimeSUnmarshaller() { return new SUnmarshaller() { private final DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime(); @Override//from w ww . j a v a 2 s.c om public Object unmarshall(final AttributeValue value) throws ParseException { return dateTimeFormatter.parseDateTime(value.getS()); } }; }
From source file:com.anrisoftware.simplerest.oanda.rest.AbstractInstrumentHistory.java
License:Open Source License
private String toRfc3339Date(DateTime date) { DateTime dt = new DateTime(date, DateTimeZone.UTC); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); return fmt.print(dt); }
From source file:com.arangodb.velocypack.module.joda.internal.util.JodaTimeUtil.java
License:Apache License
public static String format(final Instant source) { return ISODateTimeFormat.dateTime().print(source); }
From source file:com.arangodb.velocypack.module.joda.internal.util.JodaTimeUtil.java
License:Apache License
public static String format(final DateTime source) { return ISODateTimeFormat.dateTime().print(source); }
From source file:com.arangodb.velocypack.module.joda.internal.util.JodaTimeUtil.java
License:Apache License
public static String format(final LocalDateTime source) { return ISODateTimeFormat.dateTime().print(source); }
From source file:com.axelor.apps.production.web.OperationOrderController.java
License:Open Source License
public void chargeByMachineHours(ActionRequest request, ActionResponse response) throws AxelorException { List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); DateTimeFormatter parser = ISODateTimeFormat.dateTime(); LocalDateTime fromDateTime = LocalDateTime.parse(request.getContext().get("fromDateTime").toString(), parser);//w w w. j a v a 2s . c o m LocalDateTime toDateTime = LocalDateTime.parse(request.getContext().get("toDateTime").toString(), parser); LocalDateTime itDateTime = new LocalDateTime(fromDateTime); if (Days.daysBetween( new LocalDate(fromDateTime.getYear(), fromDateTime.getMonthOfYear(), fromDateTime.getDayOfMonth()), new LocalDate(toDateTime.getYear(), toDateTime.getMonthOfYear(), toDateTime.getDayOfMonth())) .getDays() > 20) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)), IException.CONFIGURATION_ERROR); } List<OperationOrder> operationOrderListTemp = operationOrderRepo.all() .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", fromDateTime, toDateTime) .fetch(); Set<String> machineNameList = new HashSet<String>(); for (OperationOrder operationOrder : operationOrderListTemp) { if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) { if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) { machineNameList.add(operationOrder.getWorkCenter().getMachine().getName()); } } } while (!itDateTime.isAfter(toDateTime)) { List<OperationOrder> operationOrderList = operationOrderRepo.all() .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", itDateTime, itDateTime.plusHours(1)) .fetch(); Map<String, BigDecimal> map = new HashMap<String, BigDecimal>(); for (OperationOrder operationOrder : operationOrderList) { if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) { String machine = operationOrder.getWorkCenter().getMachine().getName(); int numberOfMinutes = 0; if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) { numberOfMinutes = Minutes.minutesBetween(itDateTime, operationOrder.getPlannedEndDateT()) .getMinutes(); } else if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) { numberOfMinutes = Minutes .minutesBetween(operationOrder.getPlannedStartDateT(), itDateTime.plusHours(1)) .getMinutes(); } else { numberOfMinutes = Minutes.minutesBetween(operationOrder.getPlannedStartDateT(), operationOrder.getPlannedEndDateT()).getMinutes(); } if (numberOfMinutes > 60) { numberOfMinutes = 60; } BigDecimal percentage = new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100)) .divide(new BigDecimal(60), 2, RoundingMode.HALF_UP); if (map.containsKey(machine)) { map.put(machine, map.get(machine).add(percentage)); } else { map.put(machine, percentage); } } } Set<String> keyList = map.keySet(); for (String key : machineNameList) { if (keyList.contains(key)) { Map<String, Object> dataMap = new HashMap<String, Object>(); if (Hours.hoursBetween(fromDateTime, toDateTime).getHours() > 24) { dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy HH:mm")); } else { dataMap.put("dateTime", (Object) itDateTime.toString("HH:mm")); } dataMap.put("charge", (Object) map.get(key)); dataMap.put("machine", (Object) key); dataList.add(dataMap); } else { Map<String, Object> dataMap = new HashMap<String, Object>(); if (Hours.hoursBetween(fromDateTime, toDateTime).getHours() > 24) { dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy HH:mm")); } else { dataMap.put("dateTime", (Object) itDateTime.toString("HH:mm")); } dataMap.put("charge", (Object) BigDecimal.ZERO); dataMap.put("machine", (Object) key); dataList.add(dataMap); } } itDateTime = itDateTime.plusHours(1); } response.setData(dataList); }
From source file:com.axelor.apps.production.web.OperationOrderController.java
License:Open Source License
public void chargeByMachineDays(ActionRequest request, ActionResponse response) throws AxelorException { List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>(); DateTimeFormatter parser = ISODateTimeFormat.dateTime(); LocalDateTime fromDateTime = LocalDateTime.parse(request.getContext().get("fromDateTime").toString(), parser);/*from w ww . ja v a 2 s . co m*/ fromDateTime = fromDateTime.withHourOfDay(0).withMinuteOfHour(0); LocalDateTime toDateTime = LocalDateTime.parse(request.getContext().get("toDateTime").toString(), parser); toDateTime = toDateTime.withHourOfDay(23).withMinuteOfHour(59); LocalDateTime itDateTime = new LocalDateTime(fromDateTime); if (Days.daysBetween( new LocalDate(fromDateTime.getYear(), fromDateTime.getMonthOfYear(), fromDateTime.getDayOfMonth()), new LocalDate(toDateTime.getYear(), toDateTime.getMonthOfYear(), toDateTime.getDayOfMonth())) .getDays() > 500) { throw new AxelorException(String.format(I18n.get(IExceptionMessage.CHARGE_MACHINE_DAYS)), IException.CONFIGURATION_ERROR); } List<OperationOrder> operationOrderListTemp = operationOrderRepo.all() .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", fromDateTime, toDateTime) .fetch(); Set<String> machineNameList = new HashSet<String>(); for (OperationOrder operationOrder : operationOrderListTemp) { if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) { if (!machineNameList.contains(operationOrder.getWorkCenter().getMachine().getName())) { machineNameList.add(operationOrder.getWorkCenter().getMachine().getName()); } } } while (!itDateTime.isAfter(toDateTime)) { List<OperationOrder> operationOrderList = operationOrderRepo.all() .filter("self.plannedStartDateT <= ?2 AND self.plannedEndDateT >= ?1", itDateTime, itDateTime.plusHours(1)) .fetch(); Map<String, BigDecimal> map = new HashMap<String, BigDecimal>(); for (OperationOrder operationOrder : operationOrderList) { if (operationOrder.getWorkCenter() != null && operationOrder.getWorkCenter().getMachine() != null) { String machine = operationOrder.getWorkCenter().getMachine().getName(); int numberOfMinutes = 0; if (operationOrder.getPlannedStartDateT().isBefore(itDateTime)) { numberOfMinutes = Minutes.minutesBetween(itDateTime, operationOrder.getPlannedEndDateT()) .getMinutes(); } else if (operationOrder.getPlannedEndDateT().isAfter(itDateTime.plusHours(1))) { numberOfMinutes = Minutes .minutesBetween(operationOrder.getPlannedStartDateT(), itDateTime.plusHours(1)) .getMinutes(); } else { numberOfMinutes = Minutes.minutesBetween(operationOrder.getPlannedStartDateT(), operationOrder.getPlannedEndDateT()).getMinutes(); } if (numberOfMinutes > 60) { numberOfMinutes = 60; } int numberOfMinutesPerDay = 0; if (operationOrder.getWorkCenter().getMachine().getWeeklyPlanning() != null) { DayPlanning dayPlanning = weeklyPlanningService.findDayPlanning( operationOrder.getWorkCenter().getMachine().getWeeklyPlanning(), new LocalDate(itDateTime)); numberOfMinutesPerDay = Minutes .minutesBetween(dayPlanning.getMorningFrom(), dayPlanning.getMorningTo()) .getMinutes(); numberOfMinutesPerDay += Minutes .minutesBetween(dayPlanning.getAfternoonFrom(), dayPlanning.getAfternoonTo()) .getMinutes(); } else { numberOfMinutesPerDay = 60 * 8; } BigDecimal percentage = new BigDecimal(numberOfMinutes).multiply(new BigDecimal(100)) .divide(new BigDecimal(numberOfMinutesPerDay), 2, RoundingMode.HALF_UP); if (map.containsKey(machine)) { map.put(machine, map.get(machine).add(percentage)); } else { map.put(machine, percentage); } } } Set<String> keyList = map.keySet(); for (String key : machineNameList) { if (keyList.contains(key)) { int found = 0; for (Map<String, Object> mapIt : dataList) { if (mapIt.get("dateTime").equals((Object) itDateTime.toString("dd/MM/yyyy")) && mapIt.get("machine").equals((Object) key)) { mapIt.put("charge", new BigDecimal(mapIt.get("charge").toString()).add(map.get(key))); found = 1; break; } } if (found == 0) { Map<String, Object> dataMap = new HashMap<String, Object>(); dataMap.put("dateTime", (Object) itDateTime.toString("dd/MM/yyyy")); dataMap.put("charge", (Object) map.get(key)); dataMap.put("machine", (Object) key); dataList.add(dataMap); } } } itDateTime = itDateTime.plusHours(1); } response.setData(dataList); }
From source file:com.bluexml.side.clazz.generator.alfresco.api.service.ValueGenerator.java
License:Open Source License
public String getPropertyTestValue(Attribute node, String seedS) throws Exception { if (node.getValueList() != null) { EnumerationLiteral enumerationLiteral = node.getValueList().getLiterals().get(0); if (enumerationLiteral.getValue() == null || enumerationLiteral.getValue().equals("")) { return enumerationLiteral.getName(); }/*from w w w.ja va 2 s . com*/ return enumerationLiteral.getValue(); } else { int seed; if (!seedS.equals("")) { seed = Integer.parseInt(seedS); } else { seed = 0; } DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime(); Date date = null; Calendar c = Calendar.getInstance(); c.set(1978 + seed, 11, 22, 13, 30, 0); date = c.getTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); String dateString = sdf.format(date); dateString = dateTimeFormatter.print(date.getTime()); Boolean bool = seed % 2 == 0; Integer integer = 5 + seed; String str = "text" + seedS; Double db = 5.65699245 + seed; Float fl = 2.345F + seed; Long lg = 634554345345L + seed; if (node instanceof Attribute) { Attribute object = (Attribute) node; if (object.getTyp() == DataType.BOOLEAN) { return bool.toString(); } else if (object.getTyp() == DataType.BYTE) { return integer.toString(); } else if (object.getTyp() == DataType.CHAR) { return str; } else if (object.getTyp() == DataType.DATE) { return dateString; } else if (object.getTyp() == DataType.DATE_TIME) { return dateString; } else if (object.getTyp() == DataType.DOUBLE) { return db.toString(); } else if (object.getTyp() == DataType.FLOAT) { return fl.toString(); } else if (object.getTyp() == DataType.INT) { return integer.toString(); } else if (object.getTyp() == DataType.LONG) { return lg.toString(); } else if (object.getTyp() == DataType.OBJECT) { // return "d:content"; return ""; } else if (object.getTyp() == DataType.SHORT) { return integer.toString(); } else if (object.getTyp() == DataType.STRING) { return str; } else if (object.getTyp() == DataType.TIME) { return dateString; } } } throw new Exception("node must be an attribute"); }
From source file:com.boxedfolder.carrot.domain.util.DateTimeDeserializer.java
License:Open Source License
@Override public DateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { DateTime dateTime = null;/*w ww . j av a2 s.co m*/ try { JsonToken currentToken = jsonParser.getCurrentToken(); System.out.println(jsonParser.getText()); if (currentToken == JsonToken.VALUE_STRING) { String dateTimeAsString = jsonParser.getText().trim(); DateTimeFormatter formatter = ISODateTimeFormat.dateTime().withZoneUTC(); dateTime = formatter.parseDateTime(dateTimeAsString); } } catch (Exception e) { throw deserializationContext.mappingException(getClass()); } return dateTime; }