List of usage examples for org.springframework.format.datetime.joda JodaDateTimeFormatAnnotationFormatterFactory JodaDateTimeFormatAnnotationFormatterFactory
JodaDateTimeFormatAnnotationFormatterFactory
From source file:com.hp.autonomy.frontend.find.core.beanconfiguration.DispatcherServletConfiguration.java
@Override public void addFormatters(final FormatterRegistry registry) { if (converters != null) { for (final Converter<?, ?> converter : converters) { registry.addConverter(converter); }// w w w . j av a 2 s . c o m } registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); }
From source file:org.wallride.web.support.ControllerUtils.java
private static String convertPropertyValueForString(Object target, PropertyDescriptor descriptor, Object propertyValue) {//w ww. ja va2s .c o m DateTimeFormat dateTimeFormat; try { dateTimeFormat = target.getClass().getDeclaredField(descriptor.getName()) .getAnnotation(DateTimeFormat.class); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } if (dateTimeFormat != null) { JodaDateTimeFormatAnnotationFormatterFactory factory = new JodaDateTimeFormatAnnotationFormatterFactory(); Printer printer = factory.getPrinter(dateTimeFormat, descriptor.getPropertyType()); return printer.print(propertyValue, LocaleContextHolder.getLocale()); } return propertyValue.toString(); }