Example usage for org.springframework.format.datetime.joda JodaDateTimeFormatAnnotationFormatterFactory JodaDateTimeFormatAnnotationFormatterFactory

List of usage examples for org.springframework.format.datetime.joda JodaDateTimeFormatAnnotationFormatterFactory JodaDateTimeFormatAnnotationFormatterFactory

Introduction

In this page you can find the example usage for org.springframework.format.datetime.joda JodaDateTimeFormatAnnotationFormatterFactory JodaDateTimeFormatAnnotationFormatterFactory.

Prototype

JodaDateTimeFormatAnnotationFormatterFactory

Source Link

Usage

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();
}