org.joda.time.format.DateTimeParser Java Examples
The following examples show how to use
org.joda.time.format.DateTimeParser.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TikaPoweredMetadataExtracter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public TikaPoweredMetadataExtracter(String extractorContext, HashSet<String> supportedMimeTypes, HashSet<String> supportedEmbedMimeTypes) { super(supportedMimeTypes, supportedEmbedMimeTypes); this.extractorContext = extractorContext; // TODO Once TIKA-451 is fixed this list will get nicer DateTimeParser[] parsersUTC = { DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'").getParser(), DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").getParser() }; DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").getParser(), DateTimeFormat.forPattern("yyyy-MM-dd").getParser(), DateTimeFormat.forPattern("yyyy/MM/dd HH:mm:ss").getParser(), DateTimeFormat.forPattern("yyyy/MM/dd").getParser(), DateTimeFormat.forPattern("EEE MMM dd hh:mm:ss zzz yyyy").getParser() }; this.tikaUTCDateFormater = new DateTimeFormatterBuilder().append(null, parsersUTC).toFormatter().withZone(DateTimeZone.UTC); this.tikaDateFormater = new DateTimeFormatterBuilder().append(null, parsers).toFormatter(); }
Example #2
Source File: Tasks.java From heroic with Apache License 2.0 | 6 votes |
private static long parseTodayInstant(String input, final Chronology chrono, long now) { final DateTime n = new DateTime(now, chrono); for (final DateTimeParser p : today) { final DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, null, null, 2000); bucket.saveField(chrono.year(), n.getYear()); bucket.saveField(chrono.monthOfYear(), n.getMonthOfYear()); bucket.saveField(chrono.dayOfYear(), n.getDayOfYear()); try { p.parseInto(bucket, input, 0); } catch (IllegalArgumentException e) { // pass-through continue; } return bucket.computeMillis(); } throw new IllegalArgumentException(input + " is not a valid instant"); }
Example #3
Source File: Tasks.java From heroic with Apache License 2.0 | 6 votes |
private static long parseFullInstant(String input, final Chronology chrono) { for (final DateTimeParser p : full) { final DateTimeParserBucket bucket = new DateTimeParserBucket(0, chrono, null, null, 2000); try { p.parseInto(bucket, input, 0); } catch (IllegalArgumentException e) { // pass-through continue; } return bucket.computeMillis(); } throw new IllegalArgumentException(input + " is not a valid instant"); }
Example #4
Source File: JodaDateUtility.java From dremio-oss with Apache License 2.0 | 5 votes |
public static DateTimeFormatter getDateTimeFormatter() { if (dateTimeTZFormat == null) { DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("yyyy-MM-dd"); DateTimeParser optionalTime = DateTimeFormat.forPattern(" HH:mm:ss").getParser(); DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser(); DateTimeParser optionalZone = DateTimeFormat.forPattern(" ZZZ").getParser(); dateTimeTZFormat = new DateTimeFormatterBuilder().append(dateFormatter).appendOptional(optionalTime) .appendOptional(optionalSec).appendOptional(optionalZone).toFormatter(); } return dateTimeTZFormat; }
Example #5
Source File: JodaDateUtility.java From dremio-oss with Apache License 2.0 | 5 votes |
public static DateTimeFormatter getTimeFormatter() { if (timeFormat == null) { DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("HH:mm:ss"); DateTimeParser optionalSec = DateTimeFormat.forPattern(".SSS").getParser(); timeFormat = new DateTimeFormatterBuilder().append(timeFormatter).appendOptional(optionalSec).toFormatter(); } return timeFormat; }
Example #6
Source File: Joda.java From crate with Apache License 2.0 | 5 votes |
public static FormatDateTimeFormatter getStrictStandardDateFormatter() { // 2014/10/10 DateTimeFormatter shortFormatter = new DateTimeFormatterBuilder() .appendFixedDecimal(DateTimeFieldType.year(), 4) .appendLiteral('/') .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2) .appendLiteral('/') .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2) .toFormatter() .withZoneUTC(); // 2014/10/10 12:12:12 DateTimeFormatter longFormatter = new DateTimeFormatterBuilder() .appendFixedDecimal(DateTimeFieldType.year(), 4) .appendLiteral('/') .appendFixedDecimal(DateTimeFieldType.monthOfYear(), 2) .appendLiteral('/') .appendFixedDecimal(DateTimeFieldType.dayOfMonth(), 2) .appendLiteral(' ') .appendFixedSignedDecimal(DateTimeFieldType.hourOfDay(), 2) .appendLiteral(':') .appendFixedSignedDecimal(DateTimeFieldType.minuteOfHour(), 2) .appendLiteral(':') .appendFixedSignedDecimal(DateTimeFieldType.secondOfMinute(), 2) .toFormatter() .withZoneUTC(); DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder().append(longFormatter.withZone(DateTimeZone.UTC).getPrinter(), new DateTimeParser[]{longFormatter.getParser(), shortFormatter.getParser(), new EpochTimeParser(true)}); return new FormatDateTimeFormatter("yyyy/MM/dd HH:mm:ss||yyyy/MM/dd||epoch_millis", builder.toFormatter().withZone(DateTimeZone.UTC), Locale.ROOT); }
Example #7
Source File: Helper.java From ETSMobile-Android2 with Apache License 2.0 | 4 votes |
private static DateTimeParser offsetElement() { return new DateTimeFormatterBuilder().appendTimeZoneOffset("Z", true, 2, 4).toParser(); }
Example #8
Source File: Helper.java From ETSMobile-Android2 with Apache License 2.0 | 4 votes |
private static DateTimeParser fractionElement() { return new DateTimeFormatterBuilder().appendLiteral('.').appendFractionOfSecond(3, 9).toParser(); }