Java Code Examples for org.joda.time.format.DateTimeFormat#forStyle()
The following examples show how to use
org.joda.time.format.DateTimeFormat#forStyle() .
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: DateTimeFormatterFactory.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new {@code DateTimeFormatter} using this factory. * <p>If no specific pattern or style has been defined, * the supplied {@code fallbackFormatter} will be used. * @param fallbackFormatter the fall-back formatter to use * when no specific factory properties have been set * @return a new date time formatter */ public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter) { DateTimeFormatter dateTimeFormatter = null; if (StringUtils.hasLength(this.pattern)) { dateTimeFormatter = DateTimeFormat.forPattern(this.pattern); } else if (this.iso != null && this.iso != ISO.NONE) { switch (this.iso) { case DATE: dateTimeFormatter = ISODateTimeFormat.date(); break; case TIME: dateTimeFormatter = ISODateTimeFormat.time(); break; case DATE_TIME: dateTimeFormatter = ISODateTimeFormat.dateTime(); break; default: throw new IllegalStateException("Unsupported ISO format: " + this.iso); } } else if (StringUtils.hasLength(this.style)) { dateTimeFormatter = DateTimeFormat.forStyle(this.style); } if (dateTimeFormatter != null && this.timeZone != null) { dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone)); } return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter); }
Example 2
Source File: DateTimeFormatterFactory.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new {@code DateTimeFormatter} using this factory. * <p>If no specific pattern or style has been defined, * the supplied {@code fallbackFormatter} will be used. * @param fallbackFormatter the fall-back formatter to use * when no specific factory properties have been set * @return a new date time formatter */ public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter) { DateTimeFormatter dateTimeFormatter = null; if (StringUtils.hasLength(this.pattern)) { dateTimeFormatter = DateTimeFormat.forPattern(this.pattern); } else if (this.iso != null && this.iso != ISO.NONE) { switch (this.iso) { case DATE: dateTimeFormatter = ISODateTimeFormat.date(); break; case TIME: dateTimeFormatter = ISODateTimeFormat.time(); break; case DATE_TIME: dateTimeFormatter = ISODateTimeFormat.dateTime(); break; default: throw new IllegalStateException("Unsupported ISO format: " + this.iso); } } else if (StringUtils.hasLength(this.style)) { dateTimeFormatter = DateTimeFormat.forStyle(this.style); } if (dateTimeFormatter != null && this.timeZone != null) { dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone)); } return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter); }
Example 3
Source File: DateTimeFormatterFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new {@code DateTimeFormatter} using this factory. * <p>If no specific pattern or style has been defined, * the supplied {@code fallbackFormatter} will be used. * @param fallbackFormatter the fall-back formatter to use when no specific * factory properties have been set (can be {@code null}). * @return a new date time formatter */ public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter) { DateTimeFormatter dateTimeFormatter = null; if (StringUtils.hasLength(this.pattern)) { dateTimeFormatter = DateTimeFormat.forPattern(this.pattern); } else if (this.iso != null && this.iso != ISO.NONE) { switch (this.iso) { case DATE: dateTimeFormatter = ISODateTimeFormat.date(); break; case TIME: dateTimeFormatter = ISODateTimeFormat.time(); break; case DATE_TIME: dateTimeFormatter = ISODateTimeFormat.dateTime(); break; case NONE: /* no-op */ break; default: throw new IllegalStateException("Unsupported ISO format: " + this.iso); } } else if (StringUtils.hasLength(this.style)) { dateTimeFormatter = DateTimeFormat.forStyle(this.style); } if (dateTimeFormatter != null && this.timeZone != null) { dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone)); } return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter); }
Example 4
Source File: DateTimeFormatterFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new {@code DateTimeFormatter} using this factory. * <p>If no specific pattern or style has been defined, * the supplied {@code fallbackFormatter} will be used. * @param fallbackFormatter the fall-back formatter to use when no specific * factory properties have been set (can be {@code null}). * @return a new date time formatter */ public DateTimeFormatter createDateTimeFormatter(DateTimeFormatter fallbackFormatter) { DateTimeFormatter dateTimeFormatter = null; if (StringUtils.hasLength(this.pattern)) { dateTimeFormatter = DateTimeFormat.forPattern(this.pattern); } else if (this.iso != null && this.iso != ISO.NONE) { switch (this.iso) { case DATE: dateTimeFormatter = ISODateTimeFormat.date(); break; case TIME: dateTimeFormatter = ISODateTimeFormat.time(); break; case DATE_TIME: dateTimeFormatter = ISODateTimeFormat.dateTime(); break; case NONE: /* no-op */ break; default: throw new IllegalStateException("Unsupported ISO format: " + this.iso); } } else if (StringUtils.hasLength(this.style)) { dateTimeFormatter = DateTimeFormat.forStyle(this.style); } if (dateTimeFormatter != null && this.timeZone != null) { dateTimeFormatter = dateTimeFormatter.withZone(DateTimeZone.forTimeZone(this.timeZone)); } return (dateTimeFormatter != null ? dateTimeFormatter : fallbackFormatter); }
Example 5
Source File: RootCauseMetricResource.java From incubator-pinot with Apache License 2.0 | 5 votes |
private static void logSlices(MetricSlice baseSlice, List<MetricSlice> slices) { final DateTimeFormatter formatter = DateTimeFormat.forStyle("LL"); LOG.info("{} - {} (base)", formatter.print(baseSlice.getStart()), formatter.print(baseSlice.getEnd())); for (MetricSlice slice : slices) { LOG.info("{} - {}", formatter.print(slice.getStart()), formatter.print(slice.getEnd())); } }
Example 6
Source File: DateTimeFormatterFactoryTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void createDateTimeFormatterWithFallback() { DateTimeFormatter fallback = DateTimeFormat.forStyle("LL"); DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback); assertThat(formatter, is(sameInstance(fallback))); }
Example 7
Source File: DateTimeFormatterFactoryTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void createDateTimeFormatterWithFallback() { DateTimeFormatter fallback = DateTimeFormat.forStyle("LL"); DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback); assertThat(formatter, is(sameInstance(fallback))); }
Example 8
Source File: DateTimeFormatterFactoryTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void createDateTimeFormatterWithFallback() throws Exception { DateTimeFormatter fallback = DateTimeFormat.forStyle("LL"); DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback); assertThat(formatter, is(sameInstance(fallback))); }