org.springframework.format.datetime.joda.JodaDateTimeFormatAnnotationFormatterFactory Java Examples
The following examples show how to use
org.springframework.format.datetime.joda.JodaDateTimeFormatAnnotationFormatterFactory.
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: FormattingConversionServiceTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("resource") public void formatFieldForAnnotationWithPlaceholders() throws Exception { GenericApplicationContext context = new GenericApplicationContext(); PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); Properties props = new Properties(); props.setProperty("dateStyle", "S-"); props.setProperty("datePattern", "M-d-yy"); ppc.setProperties(props); context.getBeanFactory().registerSingleton("ppc", ppc); context.refresh(); context.getBeanFactory().initializeBean(formattingService, "formattingService"); formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false); }
Example #2
Source File: FormattingConversionServiceTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("resource") public void formatFieldForAnnotationWithPlaceholders() throws Exception { GenericApplicationContext context = new GenericApplicationContext(); PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); Properties props = new Properties(); props.setProperty("dateStyle", "S-"); props.setProperty("datePattern", "M-d-yy"); ppc.setProperties(props); context.getBeanFactory().registerSingleton("ppc", ppc); context.refresh(); context.getBeanFactory().initializeBean(formattingService, "formattingService"); formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false); }
Example #3
Source File: FormattingConversionServiceTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test @SuppressWarnings("resource") public void testFormatFieldForAnnotationWithPlaceholders() throws Exception { GenericApplicationContext context = new GenericApplicationContext(); PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); Properties props = new Properties(); props.setProperty("dateStyle", "S-"); props.setProperty("datePattern", "M-d-yy"); ppc.setProperties(props); context.getBeanFactory().registerSingleton("ppc", ppc); context.refresh(); context.getBeanFactory().initializeBean(formattingService, "formattingService"); formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(ModelWithPlaceholders.class, false); }
Example #4
Source File: DispatcherServletConfiguration.java From find with MIT License | 5 votes |
@Override public void addFormatters(final FormatterRegistry registry) { if(converters != null) { for(final Converter<?, ?> converter : converters) { registry.addConverter(converter); } } registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); }
Example #5
Source File: ControllerUtils.java From wallride with Apache License 2.0 | 5 votes |
private static String convertPropertyValueForString(Object target, PropertyDescriptor descriptor, Object propertyValue) { 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(); }
Example #6
Source File: FormattingConversionServiceTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void formatFieldForAnnotation() throws Exception { formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(Model.class, false); }
Example #7
Source File: FormattingConversionServiceTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void formatFieldForAnnotationWithDirectFieldAccess() throws Exception { formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(Model.class, true); }
Example #8
Source File: FormattingConversionServiceTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void formatFieldForAnnotation() throws Exception { formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(Model.class, false); }
Example #9
Source File: FormattingConversionServiceTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void formatFieldForAnnotationWithDirectFieldAccess() throws Exception { formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(Model.class, true); }
Example #10
Source File: FormattingConversionServiceTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void testFormatFieldForAnnotation() throws Exception { formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(Model.class, false); }
Example #11
Source File: FormattingConversionServiceTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Test public void testFormatFieldForAnnotationWithDirectFieldAccess() throws Exception { formattingService.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); doTestFormatFieldForAnnotation(Model.class, true); }