List of usage examples for org.joda.time.format ISODateTimeFormat timeElementParser
public static DateTimeFormatter timeElementParser()
From source file:org.apache.druid.java.util.common.parsers.TimestampParser.java
License:Apache License
private static DateTimeFormatter createAutoParser() { final DateTimeFormatter offsetElement = new DateTimeFormatterBuilder().appendTimeZoneOffset("Z", true, 2, 4) .toFormatter();/*from w w w .j a v a2 s . c o m*/ DateTimeParser timeOrOffset = new DateTimeFormatterBuilder() .append(null, new DateTimeParser[] { new DateTimeFormatterBuilder().appendLiteral('T').toParser(), new DateTimeFormatterBuilder().appendLiteral(' ').toParser() }) .appendOptional(ISODateTimeFormat.timeElementParser().getParser()) .appendOptional(offsetElement.getParser()).toParser(); return new DateTimeFormatterBuilder().append(ISODateTimeFormat.dateElementParser()) .appendOptional(timeOrOffset).toFormatter(); }
From source file:org.apache.druid.query.expression.TimestampParseExprMacro.java
License:Apache License
/** * Default formatter that parses according to the docs for this method: "If the pattern is not provided, this parses * time strings in either ISO8601 or SQL format." *//*from ww w.j a v a 2s.c om*/ private static DateTimes.UtcFormatter createDefaultParser(final DateTimeZone timeZone) { final DateTimeFormatter offsetElement = new DateTimeFormatterBuilder().appendTimeZoneOffset("Z", true, 2, 4) .toFormatter(); DateTimeParser timeOrOffset = new DateTimeFormatterBuilder() .append(null, new DateTimeParser[] { new DateTimeFormatterBuilder().appendLiteral('T').toParser(), new DateTimeFormatterBuilder().appendLiteral(' ').toParser() }) .appendOptional(ISODateTimeFormat.timeElementParser().getParser()) .appendOptional(offsetElement.getParser()).toParser(); return DateTimes.wrapFormatter(new DateTimeFormatterBuilder().append(ISODateTimeFormat.dateElementParser()) .appendOptional(timeOrOffset).toFormatter().withZone(timeZone)); }