use of org.simpleflatmapper.util.date.DefaultDateFormatSupplier in project SimpleFlatMapper by arnaudroger.
the class JodaTimeHelper method getDateTimeFormatter.
public static DateTimeFormatter getDateTimeFormatter(Object... properties) {
final DateTimeZone dateTimeZone = getDateTimeZone(properties);
DefaultDateFormatSupplier defaultDateFormatSupplier = null;
for (Object prop : properties) {
DateTimeFormatter dateTimeFormatter = toDateTimeFormater(prop, dateTimeZone);
if (dateTimeFormatter != null) {
return dateTimeFormatter;
} else if (prop instanceof DefaultDateFormatSupplier) {
defaultDateFormatSupplier = (DefaultDateFormatSupplier) prop;
}
}
if (defaultDateFormatSupplier != null) {
return withZone(defaultDateFormatSupplier.get(), dateTimeZone);
}
return null;
}
use of org.simpleflatmapper.util.date.DefaultDateFormatSupplier in project SimpleFlatMapper by arnaudroger.
the class JodaTimeHelperTest method testGetFormattersAndDefaultFormat.
@Test
public void testGetFormattersAndDefaultFormat() {
LocalDateTime localDateTime = LocalDateTime.now();
assertEquals(DateTimeFormat.forPattern("yyyy").print(localDateTime), JodaTimeHelper.getDateTimeFormatters(new DefaultDateFormatSupplier() {
@Override
public String get() {
return "yyyy";
}
})[0].print(localDateTime));
DateTimeFormatter[] dateTimeFormatters = JodaTimeHelper.getDateTimeFormatters(new DefaultDateFormatSupplier() {
@Override
public String get() {
return "yyyy";
}
}, DateTimeFormat.fullDate());
assertEquals(1, dateTimeFormatters.length);
assertEquals(DateTimeFormat.fullDate().print(localDateTime), dateTimeFormatters[0].print(localDateTime));
}
use of org.simpleflatmapper.util.date.DefaultDateFormatSupplier in project SimpleFlatMapper by arnaudroger.
the class JodaTimeHelperTest method testGetFormatterAndDefaultFormat.
@Test
public void testGetFormatterAndDefaultFormat() {
LocalDateTime localDateTime = LocalDateTime.now();
assertEquals(DateTimeFormat.forPattern("yyyy").print(localDateTime), JodaTimeHelper.getDateTimeFormatter(new DefaultDateFormatSupplier() {
@Override
public String get() {
return "yyyy";
}
}).print(localDateTime));
assertEquals(DateTimeFormat.fullDate().print(localDateTime), JodaTimeHelper.getDateTimeFormatter(new DefaultDateFormatSupplier() {
@Override
public String get() {
return "yyyy";
}
}, DateTimeFormat.fullDate()).print(localDateTime));
}
Aggregations