List of usage examples for org.springframework.format.datetime.joda JodaDateTimeFormatAnnotationFormatterFactory getPrinter
@Override
public Printer<?> getPrinter(DateTimeFormat annotation, Class<?> fieldType)
From source file:org.wallride.web.support.ControllerUtils.java
private static String convertPropertyValueForString(Object target, PropertyDescriptor descriptor, Object propertyValue) {//from ww w. j a v a 2s . co 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(); }