private DateTimeFormatter getFallbackFormatter(Type type) { switch (type) { case DATE: return DateTimeFormat.shortDate(); case TIME: return DateTimeFormat.shortTime(); default: return DateTimeFormat.shortDateTime(); } }
private static DateTimeFormatter dateHourMinuteSecond() { if (dhms == null) { return new DateTimeFormatterBuilder() .append(date()) .append(literalTElement()) .append(hourMinuteSecond()) .toFormatter(); } return dhms; }
private static DateTimeFormatter weekDateTimeNoMillis() { if (wdtx == null) { return new DateTimeFormatterBuilder() .append(weekDate()) .append(tTimeNoMillis()) .toFormatter(); } return wdtx; }
private void write(SerializeWriter out, ReadablePartial object, String format) { DateTimeFormatter formatter; if (format == formatter_iso8601_pattern) { formatter = formatter_iso8601; } else { formatter = DateTimeFormat.forPattern(format); } String text = formatter.print(object); out.writeString(text); } }
@Override public String print(Long instant, Locale locale) { return JodaTimeContextHolder.getFormatter(this.formatter, locale).print(instant); }
@Override public DateTime parse(String text, Locale locale) throws ParseException { return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseDateTime(text); }
private static DateTimeFormatter localTimeParser() { if (ltp == null) { return new DateTimeFormatterBuilder() .appendOptional(literalTElement().getParser()) .append(timeElementParser()) .toFormatter().withZoneUTC(); } return ltp; }
private static DateTimeFormatter timeParser() { if (tp == null) { return new DateTimeFormatterBuilder() .appendOptional(literalTElement().getParser()) .append(timeElementParser()) .appendOptional(offsetElement().getParser()) .toFormatter(); } return tp; }
private static DateTimeFormatter dateHour() { if (dh == null) { return new DateTimeFormatterBuilder() .append(date()) .append(literalTElement()) .append(hour()) .toFormatter(); } return dh; }
private static DateTimeFormatter dateHourMinute() { if (dhm == null) { return new DateTimeFormatterBuilder() .append(date()) .append(literalTElement()) .append(hourMinute()) .toFormatter(); } return dhm; }
private static DateTimeFormatter dateTime() { if (dt == null) { return new DateTimeFormatterBuilder() .append(date()) .append(tTime()) .toFormatter(); } return dt; }
private static DateTimeFormatter dateTimeNoMillis() { if (dtx == null) { return new DateTimeFormatterBuilder() .append(date()) .append(tTimeNoMillis()) .toFormatter(); } return dtx; }
private static DateTimeFormatter weekDateTime() { if (wdt == null) { return new DateTimeFormatterBuilder() .append(weekDate()) .append(tTime()) .toFormatter(); } return wdt; }
private DateTimeFormatter applyLocale(DateTimeFormatter dateTimeFormatter) { return dateTimeFormatter.withLocale(Locale.US); }
@Override public LocalDate parse(String text, Locale locale) throws ParseException { return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalDate(text); }
@Override public LocalDateTime parse(String text, Locale locale) throws ParseException { return JodaTimeContextHolder.getFormatter(this.formatter, locale).parseLocalDateTime(text); }
public void printTo( Appendable appenadble, long instant, Chronology chrono, int displayOffset, DateTimeZone displayZone, Locale locale) throws IOException { InternalPrinter p = getFormatter(locale).getPrinter0(); p.printTo(appenadble, instant, chrono, displayOffset, displayZone, locale); }
/** * Create a new {@code DateTimeFormatter} using this factory. * <p>If no specific pattern or style has been defined, * {@link DateTimeFormat#mediumDateTime() medium date time format} will be used. * @return a new date time formatter * @see #createDateTimeFormatter(DateTimeFormatter) */ public DateTimeFormatter createDateTimeFormatter() { return createDateTimeFormatter(DateTimeFormat.mediumDateTime()); }
@Override public String print(ReadableInstant instant, Locale locale) { return JodaTimeContextHolder.getFormatter(this.formatter, locale).print(instant); }
@Override public String print(ReadablePartial partial, Locale locale) { return JodaTimeContextHolder.getFormatter(this.formatter, locale).print(partial); }