org.springframework.format.FormatterRegistry Java Examples
The following examples show how to use
org.springframework.format.FormatterRegistry.
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: DefaultFormattingConversionService.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Add formatters appropriate for most environments: including number formatters, * JSR-354 Money & Currency formatters, JSR-310 Date-Time and/or Joda-Time formatters, * depending on the presence of the corresponding API on the classpath. * @param formatterRegistry the service to register default formatters with */ public static void addDefaultFormatters(FormatterRegistry formatterRegistry) { // Default handling of number values formatterRegistry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory()); // Default handling of monetary values if (jsr354Present) { formatterRegistry.addFormatter(new CurrencyUnitFormatter()); formatterRegistry.addFormatter(new MonetaryAmountFormatter()); formatterRegistry.addFormatterForFieldAnnotation(new Jsr354NumberFormatAnnotationFormatterFactory()); } // Default handling of date-time values if (jsr310Present) { // just handling JSR-310 specific date and time types new DateTimeFormatterRegistrar().registerFormatters(formatterRegistry); } if (jodaTimePresent) { // handles Joda-specific types as well as Date, Calendar, Long new JodaTimeFormatterRegistrar().registerFormatters(formatterRegistry); } else { // regular DateFormat-based Date, Calendar, Long converters new DateFormatterRegistrar().registerFormatters(formatterRegistry); } }
Example #2
Source File: JodaTimeFormatterRegistrar.java From spring-analysis-note with MIT License | 5 votes |
private void addFormatterForFields(FormatterRegistry registry, Printer<?> printer, Parser<?> parser, Class<?>... fieldTypes) { for (Class<?> fieldType : fieldTypes) { registry.addFormatterForFieldType(fieldType, printer, parser); } }
Example #3
Source File: WebConfig.java From tutorials with MIT License | 5 votes |
@Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new StringToEmployeeConverter()); registry.addConverter(new StringToEnumConverter()); registry.addConverterFactory(new StringToAbstractEntityConverterFactory()); registry.addConverter(new GenericBigDecimalConverter()); }
Example #4
Source File: DateFormatterRegistrar.java From spring-analysis-note with MIT License | 5 votes |
@Override public void registerFormatters(FormatterRegistry registry) { addDateConverters(registry); registry.addFormatterForFieldAnnotation(new DateTimeFormatAnnotationFormatterFactory()); // In order to retain back compatibility we only register Date/Calendar // types when a user defined formatter is specified (see SPR-10105) if (this.dateFormatter != null) { registry.addFormatter(this.dateFormatter); registry.addFormatterForFieldType(Calendar.class, this.dateFormatter); } }
Example #5
Source File: WebMvcConfigurationSupportExtensionTests.java From java-technology-stack with MIT License | 5 votes |
@Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new Converter<TestBean, String>() { @Override public String convert(TestBean source) { return "converted"; } }); }
Example #6
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 #7
Source File: BootMvcConfigurerAdapter.java From onetwo with Apache License 2.0 | 5 votes |
@Override public void addFormatters(FormatterRegistry registry) { registry.removeConvertible(String.class, Enum.class); registry.addConverterFactory(new IntStringValueToEnumConverterFactory()); registry.addConverterFactory(new IntegerToEnumConverterFactory()); }
Example #8
Source File: DateFormatterRegistrar.java From java-technology-stack with MIT License | 5 votes |
@Override public void registerFormatters(FormatterRegistry registry) { addDateConverters(registry); registry.addFormatterForFieldAnnotation(new DateTimeFormatAnnotationFormatterFactory()); // In order to retain back compatibility we only register Date/Calendar // types when a user defined formatter is specified (see SPR-10105) if (this.dateFormatter != null) { registry.addFormatter(this.dateFormatter); registry.addFormatterForFieldType(Calendar.class, this.dateFormatter); } }
Example #9
Source File: WebConfiguration.java From Spring-Boot-2.0-Cookbook-Second-Edition with MIT License | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { registry.addFormatter(new BookFormatter(bookRepository)); }
Example #10
Source File: DateTimeFormatConfiguration.java From e-commerce-microservice with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }
Example #11
Source File: WebConfig.java From Spring with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry formatterRegistry) { formatterRegistry.addFormatter(dateFormatter()); }
Example #12
Source File: WebConfiguration.java From Spring-Boot-2.0-Cookbook-Second-Edition with MIT License | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { registry.addFormatter(new BookFormatter(bookRepository)); }
Example #13
Source File: WebConfig.java From tutorials with MIT License | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { registry.addConverter(new StringToEmployeeConverter()); registry.addConverterFactory(new StringToEnumConverterFactory()); registry.addConverter(new GenericBigDecimalConverter()); }
Example #14
Source File: DelegatingWebFluxConfiguration.java From java-technology-stack with MIT License | 4 votes |
@Override protected void addFormatters(FormatterRegistry registry) { this.configurers.addFormatters(registry); }
Example #15
Source File: ThymeleafConfig.java From taoshop with Apache License 2.0 | 4 votes |
@Override public void addFormatters(final FormatterRegistry registry){ super.addFormatters(registry); registry.addFormatter(dateFormatter()); }
Example #16
Source File: DateTimeFormatConfiguration.java From jhipster-microservices-example with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }
Example #17
Source File: JodaTimeFormatterRegistrar.java From spring4-understanding with Apache License 2.0 | 4 votes |
public static void registerAdditionalFormatters(FormatterRegistry registry) { registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter()); registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter()); }
Example #18
Source File: WebConfiguration.java From Spring-Boot-2.0-Cookbook-Second-Edition with MIT License | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { registry.addFormatter(new BookFormatter(bookRepository)); }
Example #19
Source File: DateTimeFormatConfiguration.java From tutorials with MIT License | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }
Example #20
Source File: EtfFormatterRegistrar.java From etf-webapp with European Union Public License 1.2 | 4 votes |
@Override public void registerFormatters(final FormatterRegistry registry) { addConverter(registry, new EidConverter()); addConverter(registry, new VersionConverter()); }
Example #21
Source File: JodaTimeFormatterRegistrar.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void registerFormatters(FormatterRegistry registry) { JodaTimeConverters.registerConverters(registry); DateTimeFormatter dateFormatter = getFormatter(Type.DATE); DateTimeFormatter timeFormatter = getFormatter(Type.TIME); DateTimeFormatter dateTimeFormatter = getFormatter(Type.DATE_TIME); addFormatterForFields(registry, new ReadablePartialPrinter(dateFormatter), new LocalDateParser(dateFormatter), LocalDate.class); addFormatterForFields(registry, new ReadablePartialPrinter(timeFormatter), new LocalTimeParser(timeFormatter), LocalTime.class); addFormatterForFields(registry, new ReadablePartialPrinter(dateTimeFormatter), new LocalDateTimeParser(dateTimeFormatter), LocalDateTime.class); addFormatterForFields(registry, new ReadableInstantPrinter(dateTimeFormatter), new DateTimeParser(dateTimeFormatter), ReadableInstant.class); // In order to retain backwards compatibility we only register Date/Calendar // types when a user defined formatter is specified (see SPR-10105) if (this.formatters.containsKey(Type.DATE_TIME)) { addFormatterForFields(registry, new ReadableInstantPrinter(dateTimeFormatter), new DateTimeParser(dateTimeFormatter), Date.class, Calendar.class); } registry.addFormatterForFieldType(Period.class, new PeriodFormatter()); registry.addFormatterForFieldType(Duration.class, new DurationFormatter()); if (jodaTime2Available) { JodaTime2Delegate.registerAdditionalFormatters(registry); } registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); }
Example #22
Source File: DefaultControllerSpec.java From java-technology-stack with MIT License | 4 votes |
@Override public DefaultControllerSpec formatters(Consumer<FormatterRegistry> consumer) { this.configurer.formattersConsumer = consumer; return this; }
Example #23
Source File: DateTimeFormatConfiguration.java From jhipster-online with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }
Example #24
Source File: FormattingConversionServiceFactoryBeanTests.java From java-technology-stack with MIT License | 4 votes |
@Override public void registerFormatters(FormatterRegistry registry) { registry.addFormatter(new TestBeanFormatter()); }
Example #25
Source File: DateTimeFormatConfiguration.java From jhipster-microservices-example with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }
Example #26
Source File: DateTimeFormatConfiguration.java From jhipster-microservices-example with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }
Example #27
Source File: JodaTimeFormatterRegistrar.java From java-technology-stack with MIT License | 4 votes |
@Override public void registerFormatters(FormatterRegistry registry) { JodaTimeConverters.registerConverters(registry); DateTimeFormatter dateFormatter = getFormatter(Type.DATE); DateTimeFormatter timeFormatter = getFormatter(Type.TIME); DateTimeFormatter dateTimeFormatter = getFormatter(Type.DATE_TIME); addFormatterForFields(registry, new ReadablePartialPrinter(dateFormatter), new LocalDateParser(dateFormatter), LocalDate.class); addFormatterForFields(registry, new ReadablePartialPrinter(timeFormatter), new LocalTimeParser(timeFormatter), LocalTime.class); addFormatterForFields(registry, new ReadablePartialPrinter(dateTimeFormatter), new LocalDateTimeParser(dateTimeFormatter), LocalDateTime.class); addFormatterForFields(registry, new ReadableInstantPrinter(dateTimeFormatter), new DateTimeParser(dateTimeFormatter), ReadableInstant.class); // In order to retain backwards compatibility we only register Date/Calendar // types when a user defined formatter is specified (see SPR-10105) if (this.formatters.containsKey(Type.DATE_TIME)) { addFormatterForFields(registry, new ReadableInstantPrinter(dateTimeFormatter), new DateTimeParser(dateTimeFormatter), Date.class, Calendar.class); } registry.addFormatterForFieldType(Period.class, new PeriodFormatter()); registry.addFormatterForFieldType(Duration.class, new DurationFormatter()); registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter()); registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter()); registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory()); }
Example #28
Source File: DateTimeFormatConfiguration.java From cubeai with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }
Example #29
Source File: JodaTimeFormatterRegistrar.java From lams with GNU General Public License v2.0 | 4 votes |
public static void registerAdditionalFormatters(FormatterRegistry registry) { registry.addFormatterForFieldType(YearMonth.class, new YearMonthFormatter()); registry.addFormatterForFieldType(MonthDay.class, new MonthDayFormatter()); }
Example #30
Source File: DateTimeFormatConfiguration.java From cubeai with Apache License 2.0 | 4 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); }