org.springframework.format.datetime.standard.DateTimeFormatterRegistrar Java Examples
The following examples show how to use
org.springframework.format.datetime.standard.DateTimeFormatterRegistrar.
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 spring-analysis-note with MIT License | 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 // 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: DefaultFormattingConversionService.java From java-technology-stack with MIT License | 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 // 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 #3
Source File: CmisServiceBridge.java From spring-content with Apache License 2.0 | 6 votes |
public CmisServiceBridge(CmisRepositoryConfiguration cmisRepositoryConfiguration) { this.cmisRepositoryConfiguration = cmisRepositoryConfiguration; for (TypeDefinition typeDef : cmisRepositoryConfiguration.getCmisTypeDefinitionList().getList()) { typeMap.put(typeDef.getId(), typeDef); } DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setDateTimeFormatter(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")); registrar.registerFormatters(conversionService); conversionService.addConverter(new Converter<Instant, GregorianCalendar>() { @Override public GregorianCalendar convert(Instant source) { ZonedDateTime zdt = ZonedDateTime.ofInstant(source, ZoneId.systemDefault()); return GregorianCalendar.from(zdt); } }); }
Example #4
Source File: DefaultFormattingConversionService.java From spring4-understanding with Apache License 2.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 #5
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 #6
Source File: TestUtil.java From tutorials with MIT License | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #7
Source File: TestUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #8
Source File: TestUtil.java From alchemy with Apache License 2.0 | 5 votes |
/** * Create a {@link FormattingConversionService} which use ISO date format, instead of the localized one. * @return the {@link FormattingConversionService}. */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #9
Source File: TestUtil.java From java-microservices-examples with Apache License 2.0 | 5 votes |
/** * Create a {@link FormattingConversionService} which use ISO date format, instead of the localized one. * @return the {@link FormattingConversionService}. */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #10
Source File: TestUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #11
Source File: TestUtil.java From tutorials with MIT License | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #12
Source File: TestUtil.java From 21-points with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #13
Source File: TestUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #14
Source File: TestUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #15
Source File: TestUtil.java From java-microservices-examples with Apache License 2.0 | 5 votes |
/** * Create a {@link FormattingConversionService} which use ISO date format, instead of the localized one. * @return the {@link FormattingConversionService}. */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #16
Source File: TestUtil.java From jhipster-registry with Apache License 2.0 | 5 votes |
/** * Create a {@link FormattingConversionService} which use ISO date format, instead of the localized one. * @return the {@link FormattingConversionService}. */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #17
Source File: TestUtil.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #18
Source File: TestUtil.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #19
Source File: TestUtil.java From ehcache3-samples with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #20
Source File: TestUtil.java From okta-jhipster-microservices-oauth-example with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #21
Source File: TestUtil.java From TeamDojo with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService(); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #22
Source File: TestUtil.java From Spring-5.0-Projects with MIT License | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #23
Source File: DateTimeFormatConfiguration.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
@Override public void addFormatters(FormatterRegistry registry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(registry); registry.addConverter(new StringToDateConverter()); }
Example #24
Source File: TestUtil.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #25
Source File: TestUtil.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #26
Source File: TestUtil.java From jhipster-online with Apache License 2.0 | 5 votes |
/** * Create a {@link FormattingConversionService} which use ISO date format, instead of the localized one. * @return the {@link FormattingConversionService}. */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #27
Source File: TestUtil.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #28
Source File: TestUtil.java From Full-Stack-Development-with-JHipster with MIT License | 5 votes |
/** * Create a FormattingConversionService which use ISO date format, instead of the localized one. * @return the FormattingConversionService */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService (); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }
Example #29
Source File: FeignDateConfiguration.java From k8s-fleetman with MIT License | 5 votes |
@Bean public FeignFormatterRegistrar localDateFeignFormatterRegistrar() { return new FeignFormatterRegistrar() { @Override public void registerFormatters(FormatterRegistry formatterRegistry) { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(formatterRegistry); } }; }
Example #30
Source File: TestUtil.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
/** * Create a {@link FormattingConversionService} which use ISO date format, instead of the localized one. * * @return the {@link FormattingConversionService}. */ public static FormattingConversionService createFormattingConversionService() { DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService(); DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); registrar.setUseIsoFormat(true); registrar.registerFormatters(dfcs); return dfcs; }