List of usage examples for org.joda.time.format ISODateTimeFormat dateTime
public static DateTimeFormatter dateTime()
From source file:org.filteredpush.qc.date.DateUtils.java
License:Apache License
/** * Attempt to extract a time from an eventDate that could contain time information. * /*from w ww .ja v a 2 s. com*/ * @param eventDate dwc:eventDate from which to try to extract a time (in UTC). * @return a string containing a time in UTC or null */ public static String extractZuluTime(String eventDate) { String result = null; if (!isEmpty(eventDate)) { if (eventDate.endsWith("UTC")) { eventDate = eventDate.replace("UTC", "Z"); } DateTimeParser[] parsers = { ISODateTimeFormat.dateHour().getParser(), ISODateTimeFormat.dateTimeParser().getParser(), ISODateTimeFormat.dateHourMinute().getParser(), ISODateTimeFormat.dateHourMinuteSecond().getParser(), ISODateTimeFormat.dateTime().getParser() }; DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter(); if (eventDate.matches("^[0-9]{4}[-][0-9]{2}[-][0-9]{2}[Tt].+")) { try { result = instantToStringTime(Instant.parse(eventDate, formatter)); logger.debug(result); } catch (Exception e) { // not a date with a time logger.error(e.getMessage()); } } if (isRange(eventDate) && eventDate.contains("/") && result != null) { String[] bits = eventDate.split("/"); if (bits != null && bits.length > 1) { // does either start or end date contain a time? if (bits[0].matches("^[0-9]{4}[-][0-9]{2}[-][0-9]{2}[Tt].+")) { try { result = instantToStringTime(Instant.parse(bits[0], formatter)); logger.debug(result); } catch (Exception e) { // not a date with a time logger.error(e.getMessage()); } } if (bits[1].matches("^[0-9]{4}[-][0-9]{2}[-][0-9]{2}[Tt].+") && result != null) { try { result = instantToStringTime(Instant.parse(bits[1], formatter)); logger.debug(result); } catch (Exception e) { // not a date with a time logger.error(e.getMessage()); } } } } } return result; }
From source file:org.flowable.cmmn.engine.impl.behavior.impl.TimerEventListenerActivityBehaviour.java
License:Apache License
public String prepareRepeat(String dueDate, Clock clock) { if (dueDate.startsWith("R") && dueDate.split("/").length == 2) { DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); return dueDate.replace("/", "/" + fmt.print( new DateTime(clock.getCurrentTime(), DateTimeZone.forTimeZone(clock.getCurrentTimeZone()))) + "/"); }/*w w w. jav a 2 s. co m*/ return dueDate; }
From source file:org.forgerock.openidm.util.DateUtil.java
License:CDDL license
/** * Parses an ISO8601 compliant timestamp into a DateTime object. * * @param timestamp/*from www .j a va2 s.c o m*/ * timestamp to parse * @return DateTime using the zone and chronology indicated by the timestamp */ public DateTime parseTimestamp(String timestamp) { DateTimeFormatter parser = ISODateTimeFormat.dateTime(); return parser.withOffsetParsed().parseDateTime(timestamp); }
From source file:org.fuin.objects4j.common.DateTimeAdapter.java
License:Open Source License
@Override public final String marshal(final DateTime value) { if (value == null) { return null; }/* ww w. ja va 2 s . com*/ return ISODateTimeFormat.dateTime().print(value); }
From source file:org.fuin.objects4j.common.DateTimeAdapter.java
License:Open Source License
@Override public final String convertToDatabaseColumn(final DateTime value) { if (value == null) { return null; }/*from w ww . j ava 2 s.co m*/ return ISODateTimeFormat.dateTime().print(value); }
From source file:org.fuin.objects4j.common.LocalDateTimeAdapter.java
License:Open Source License
@Override public final String marshal(final LocalDateTime value) { if (value == null) { return null; }//from w w w .j a v a2s .c o m return ISODateTimeFormat.dateTime().print(value); }
From source file:org.fuin.objects4j.common.LocalDateTimeAdapter.java
License:Open Source License
@Override public final String convertToDatabaseColumn(final LocalDateTime value) { if (value == null) { return null; }//from w w w . j a va 2 s .c o m return ISODateTimeFormat.dateTime().print(value); }
From source file:org.gephi.desktop.timeline.TimelineTooltip.java
License:Open Source License
private void buildData(double currentPosition) { if (model.getTimeFormat().equals(TimeFormat.DOUBLE)) { int exponentMin = (int) Math.round(Math.log10(model.getCustomMin())); DecimalFormat decimalFormat = new DecimalFormat(); decimalFormat.setRoundingMode(RoundingMode.HALF_EVEN); if (exponentMin > 0) { min = String.valueOf(model.getCustomMin()); max = String.valueOf(model.getCustomMax()); position = String.valueOf(currentPosition); } else {/*from w ww.j av a2 s.c om*/ decimalFormat.setMaximumFractionDigits(Math.abs(exponentMin) + 2); min = decimalFormat.format(model.getCustomMin()); max = decimalFormat.format(model.getCustomMax()); position = decimalFormat.format(currentPosition); } } else if (model.getTimeFormat().equals(TimeFormat.DATE)) { DateTime minDate = new DateTime((long) model.getCustomMin()); DateTime maxDate = new DateTime((long) model.getCustomMax()); DateTime posDate = new DateTime((long) currentPosition); DateTimeFormatter formatter = ISODateTimeFormat.date(); min = formatter.print(minDate); max = formatter.print(maxDate); position = formatter.print(posDate); } else { DateTime minDate = new DateTime((long) model.getCustomMin()); DateTime maxDate = new DateTime((long) model.getCustomMax()); DateTime posDate = new DateTime((long) currentPosition); DateTimeFormatter formatter = ISODateTimeFormat.dateTime(); min = formatter.print(minDate); max = formatter.print(maxDate); position = formatter.print(posDate); } if (model.getChart() != null) { TimelineChart chart = model.getChart(); Number yNumber = chart.getY(currentPosition); y = yNumber != null ? yNumber.toString() : null; } else { y = null; } }
From source file:org.gluu.oxtrust.service.antlr.scimFilter.util.GluuCustomPersonListSerializer.java
License:MIT License
private void writeStructure(String parent, Map.Entry<String, JsonNode> rootNodeEntry, ObjectMapper mapper, ScimPerson scimPerson, JsonGenerator jsonGenerator) throws Exception { jsonGenerator.writeFieldName(rootNodeEntry.getKey()); if (rootNodeEntry.getValue() instanceof ObjectNode) { jsonGenerator.writeStartObject(); processNodes(rootNodeEntry.getKey(), rootNodeEntry.getValue(), mapper, scimPerson, jsonGenerator); // Recursion jsonGenerator.writeEndObject();// w w w . j a v a 2 s . c o m } else if (rootNodeEntry.getValue() instanceof ArrayNode) { ArrayNode arrayNode = (ArrayNode) rootNodeEntry.getValue(); jsonGenerator.writeStartArray(); if (rootNodeEntry.getKey().equalsIgnoreCase("schemas")) { for (int i = 0; i < arrayNode.size(); i++) { JsonNode arrayNodeElement = arrayNode.get(i); jsonGenerator.writeObject(arrayNodeElement); } } else { if (arrayNode.size() > 0) { for (int i = 0; i < arrayNode.size(); i++) { JsonNode arrayNodeElement = arrayNode.get(i); if (arrayNodeElement.isObject()) { jsonGenerator.writeStartObject(); processNodes(rootNodeEntry.getKey(), arrayNodeElement, mapper, scimPerson, jsonGenerator); // Recursion jsonGenerator.writeEndObject(); } else { jsonGenerator.writeObject(arrayNodeElement); } } } } jsonGenerator.writeEndArray(); } else { if (parent != null && parent.equalsIgnoreCase("meta")) { if (rootNodeEntry.getValue() instanceof LongNode && (rootNodeEntry.getKey().equalsIgnoreCase("created") || rootNodeEntry.getKey().equalsIgnoreCase("lastModified"))) { DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC(); // Date should be in UTC format // In millis convert to string date jsonGenerator.writeObject( dateTimeFormatter.print(Long.valueOf(rootNodeEntry.getValue().asText()).longValue())); } else { jsonGenerator.writeObject(rootNodeEntry.getValue()); } } else { jsonGenerator.writeObject(rootNodeEntry.getValue()); } } }
From source file:org.gluu.oxtrust.service.antlr.scimFilter.util.GluuGroupListSerializer.java
License:MIT License
private void writeStructure(String parent, Map.Entry<String, JsonNode> rootNodeEntry, JsonGenerator jsonGenerator) throws Exception { jsonGenerator.writeFieldName(rootNodeEntry.getKey()); if (rootNodeEntry.getValue() instanceof ObjectNode) { jsonGenerator.writeStartObject(); processNodes(rootNodeEntry.getKey(), rootNodeEntry.getValue(), jsonGenerator); // Recursion jsonGenerator.writeEndObject();/*from w w w .j av a 2s .c o m*/ } else if (rootNodeEntry.getValue() instanceof ArrayNode) { ArrayNode arrayNode = (ArrayNode) rootNodeEntry.getValue(); jsonGenerator.writeStartArray(); if (arrayNode.size() > 0) { for (int i = 0; i < arrayNode.size(); i++) { JsonNode arrayNodeElement = arrayNode.get(i); if (arrayNodeElement.isObject()) { jsonGenerator.writeStartObject(); processNodes(rootNodeEntry.getKey(), arrayNodeElement, jsonGenerator); // Recursion jsonGenerator.writeEndObject(); } else { jsonGenerator.writeObject(arrayNodeElement); } } } jsonGenerator.writeEndArray(); } else { if (parent != null && parent.equalsIgnoreCase("meta")) { if (rootNodeEntry.getValue() instanceof LongNode && (rootNodeEntry.getKey().equalsIgnoreCase("created") || rootNodeEntry.getKey().equalsIgnoreCase("lastModified"))) { DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC(); // Date should be in UTC format // In millis convert to string date jsonGenerator.writeObject( dateTimeFormatter.print(Long.valueOf(rootNodeEntry.getValue().asText()).longValue())); } else { jsonGenerator.writeObject(rootNodeEntry.getValue()); } } else { jsonGenerator.writeObject(rootNodeEntry.getValue()); } } }