Here are the examples of the java api org.springframework.format.FormatterRegistry taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
75 Examples
19
Source : DateFormatRegister.java
with Apache License 2.0
from zuihou
with Apache License 2.0
from zuihou
@Override
public void registerFormatters(FormatterRegistry registry) {
registry.addConverter(Date.clreplaced, String.clreplaced, new Date2StringConverter());
registry.addConverter(LocalDateTime.clreplaced, String.clreplaced, new LocalDateTime2StringConverter());
registry.addConverter(LocalDate.clreplaced, String.clreplaced, new LocalDate2StringConverter());
registry.addConverter(LocalTime.clreplaced, String.clreplaced, new LocalTime2StringConverter());
}
19
Source : WebMvcConfig.java
with MIT License
from zhaojun1998
with MIT License
from zhaojun1998
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new StorageTypeEnumDeSerializerConvert());
}
19
Source : WebConfig.java
with GNU General Public License v3.0
from yushijinhun
with GNU General Public License v3.0
from yushijinhun
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new StringToTextureTypeConverter());
}
19
Source : SpringConfig.java
with Apache License 2.0
from yujunhao8831
with Apache License 2.0
from yujunhao8831
/**
* 添加转换器
*
* @param registry
*/
@Override
public void addFormatters(FormatterRegistry registry) {
// 从前台过来的数据转换成对应类型的转换器,但是对 @RequestBody 注解的参数无效
registry.addConverter(new StringToDateConverter());
}
19
Source : WebConfig.java
with MIT License
from yuantiku
with MIT License
from yuantiku
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new StringToUserConverter());
}
19
Source : ApplicationConversionService.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
/**
* Add formatters useful for most Spring Boot applications.
* @param registry the service to register default formatters with
*/
public static void addApplicationFormatters(FormatterRegistry registry) {
registry.addFormatter(new CharArrayFormatter());
registry.addFormatter(new InetAddressFormatter());
registry.addFormatter(new IsoOffsetFormatter());
}
19
Source : ApplicationConversionService.java
with Apache License 2.0
from yuanmabiji
with Apache License 2.0
from yuanmabiji
/**
* Configure the given {@link FormatterRegistry} with formatters and converters
* appropriate for most Spring Boot applications.
* @param registry the registry of converters to add to (must also be castable to
* ConversionService, e.g. being a {@link ConfigurableConversionService})
* @throws ClreplacedCastException if the given FormatterRegistry could not be cast to a
* ConversionService
*/
public static void configure(FormatterRegistry registry) {
DefaultConversionService.addDefaultConverters(registry);
DefaultFormattingConversionService.addDefaultFormatters(registry);
addApplicationFormatters(registry);
addApplicationConverters(registry);
}
19
Source : JiaJiaLeApplication.java
with Apache License 2.0
from yizhuoyan
with Apache License 2.0
from yizhuoyan
@Override
public void addFormatters(FormatterRegistry registry) {
// 添加字符串清理coverter
registry.addConverter(new StringTrimConverter());
}
19
Source : ResourcesConfiguration.java
with Apache License 2.0
from yin5980280
with Apache License 2.0
from yin5980280
@Override
public void addFormatters(final FormatterRegistry registry) {
registry.addFormatter(dateFormatter());
}
19
Source : DateFormatRegister.java
with GNU General Public License v3.0
from xiaomujiayou
with GNU General Public License v3.0
from xiaomujiayou
@Override
public void registerFormatters(FormatterRegistry registry) {
registry.addConverter(Date.clreplaced, String.clreplaced, new Date2StringConverter());
}
19
Source : WebMvcConfigurerComposite.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Override
public void addFormatters(FormatterRegistry registry) {
for (WebMvcConfigurer delegate : this.delegates) {
delegate.addFormatters(registry);
}
}
19
Source : WebMvcConfigurerAdapter.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* {@inheritDoc}
* <p>This implementation is empty.
*/
@Override
public void addFormatters(FormatterRegistry registry) {
}
19
Source : WebMvcConfigurationSupport.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Override this method to add custom {@link Converter} and/or {@link Formatter}
* delegates to the common {@link FormattingConversionService}.
* @see #mvcConversionService()
*/
protected void addFormatters(FormatterRegistry registry) {
}
19
Source : DelegatingWebMvcConfiguration.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Override
protected void addFormatters(FormatterRegistry registry) {
this.configurers.addFormatters(registry);
}
19
Source : WebFluxConfigurerComposite.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@Override
public void addFormatters(FormatterRegistry registry) {
this.delegates.forEach(delegate -> delegate.addFormatters(registry));
}
19
Source : WebFluxConfigurationSupport.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* Override this method to add custom {@link Converter} and/or {@link Formatter}
* delegates to the common {@link FormattingConversionService}.
* @see #webFluxConversionService()
*/
protected void addFormatters(FormatterRegistry registry) {
}
19
Source : DefaultFormattingConversionService.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
/**
* 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 clreplacedpath.
* @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);
}
}
19
Source : JodaTimeFormatterRegistrar.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
private void addFormatterForFields(FormatterRegistry registry, Printer<?> printer, Parser<?> parser, Clreplaced<?>... fieldTypes) {
for (Clreplaced<?> fieldType : fieldTypes) {
registry.addFormatterForFieldType(fieldType, printer, parser);
}
}
19
Source : DateFormatterRegistrar.java
with MIT License
from Vip-Augus
with MIT License
from Vip-Augus
@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.clreplaced, this.dateFormatter);
}
}
19
Source : ThymeleafConfig.java
with Apache License 2.0
from u014427391
with Apache License 2.0
from u014427391
@Override
public void addFormatters(final FormatterRegistry registry) {
super.addFormatters(registry);
registry.addFormatter(dateFormatter());
}
19
Source : WebMvcConfiguration.java
with Apache License 2.0
from springdoc
with Apache License 2.0
from springdoc
@Override
public void addFormatters(FormatterRegistry registry) {
ApplicationConversionService.configure(registry);
}
19
Source : DefaultFormattingConversionService.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
/**
* 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 clreplacedpath.
* @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) {
// 添加 jsr 354 中时间和金钱的format
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
// 追加 format register
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);
}
}
19
Source : DateFormatterRegistrar.java
with Apache License 2.0
from SourceHot
with Apache License 2.0
from SourceHot
@Override
public void registerFormatters(FormatterRegistry registry) {
addDateConverters(registry);
// 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.clreplaced, this.dateFormatter);
}
registry.addFormatterForFieldAnnotation(new DateTimeFormatAnnotationFormatterFactory());
}
19
Source : FilterRegister.java
with Apache License 2.0
from rkonovalov
with Apache License 2.0
from rkonovalov
@Override
public void addFormatters(FormatterRegistry registry) {
// Do nothing
}
19
Source : WebConfig.java
with MIT License
from pzinsta
with MIT License
from pzinsta
@Override
public void addFormatters(FormatterRegistry registry) {
DateFormatter dateFormatter = new DateFormatter();
dateFormatter.setStyle(DateFormat.MEDIUM);
registry.addFormatter(dateFormatter);
}
19
Source : LocaleConfiguration.java
with GNU Affero General Public License v3.0
from progilone
with GNU Affero General Public License v3.0
from progilone
@Override
public void addFormatters(final FormatterRegistry registry) {
// Par défaut, Spring split les paramètres de type String[] sur le caractère virgule;
// c'est un comportement non désiré, notamment sur les requêtes de recherche.
registry.removeConvertible(String.clreplaced, String[].clreplaced);
registry.addConverter(String.clreplaced, String[].clreplaced, source -> StringUtils.isNotBlank(source) ? new String[] { source } : new String[] {});
}
19
Source : WebConfiguration.java
with MIT License
from PacktPublishing
with MIT License
from PacktPublishing
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(new BookFormatter(bookRepository));
}
19
Source : ConvertWebMvcConfigurer.java
with Apache License 2.0
from open-hand
with Apache License 2.0
from open-hand
@Override
public void addFormatters(FormatterRegistry registry) {
if (enable) {
registry.addConverter(new DateConverter());
registry.addConverter(new LocalDateConverter());
}
}
19
Source : WebCoreMvcAutoConfiguration.java
with Apache License 2.0
from mayee
with Apache License 2.0
from mayee
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverterFactory(new IEnumConverterFactory());
}
19
Source : WebConfig.java
with MIT License
from lzpeng723
with MIT License
from lzpeng723
/**
* 枚举类的转换器工厂 addConverterFactory
*/
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverterFactory(new IntegerToEnumConverterFactory());
registry.addConverterFactory(new StringToIntEnumConverterFactory());
}
19
Source : WebMvcConfigurer.java
with MIT License
from liuxx-u
with MIT License
from liuxx-u
@Override
public void addFormatters(FormatterRegistry registry) {
ApplicationConversionService.addBeans(registry, this.beanFactory);
}
19
Source : EnableWebMvcConfiguration.java
with Apache License 2.0
from LinkedBear
with Apache License 2.0
from LinkedBear
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new String2DateConverter());
}
19
Source : WebMvcConfigurationSupport.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* Override this method to add custom {@link Converter}s and {@link Formatter}s.
*/
protected void addFormatters(FormatterRegistry registry) {
}
19
Source : DefaultFormattingConversionService.java
with Apache License 2.0
from langtianya
with Apache License 2.0
from langtianya
/**
* 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 clreplacedpath.
* @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);
}
}
19
Source : WebMvcConfig.java
with Apache License 2.0
from kellen0903
with Apache License 2.0
from kellen0903
@Override
public void addFormatters(FormatterRegistry formatterRegistry) {
}
19
Source : WebConfigurer.java
with GNU General Public License v2.0
from Jigsawk
with GNU General Public License v2.0
from Jigsawk
@Override
public void addFormatters(FormatterRegistry registry) {
}
19
Source : SpringConnectorWebMvc.java
with Apache License 2.0
from interledger4j
with Apache License 2.0
from interledger4j
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(rateLimitSettingsEnreplacedyConverter);
registry.addConverter(accountBalanceSettingsEnreplacedyConverter);
registry.addConverter(settlementEngineDetailsEnreplacedyConverter);
registry.addConverter(accountSettingsConverter);
registry.addConverter(fxRateOverrideEnreplacedyConverter);
registry.addConverter(staticRouteEnreplacedyConverter);
registry.addConverter(accessTokenEnreplacedyConverter);
}
19
Source : IFSWebConfiguration.java
with MIT License
from InnovateUKGitHub
with MIT License
from InnovateUKGitHub
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(new RejectionReasonFormatter());
}
19
Source : WebMvcConfig.java
with MIT License
from HiCooper
with MIT License
from HiCooper
/**
* 添加类型转换器和格式化器
*
* @param registry registry
*/
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatterForFieldType(Date.clreplaced, new DateFormatter());
}
19
Source : ApplicationConversionService.java
with Apache License 2.0
from hello-shf
with Apache License 2.0
from hello-shf
/**
* Add formatters useful for most Spring Boot applications.
*
* @param registry the service to register default formatters with
*/
public static void addApplicationFormatters(FormatterRegistry registry) {
registry.addFormatter(new CharArrayFormatter());
registry.addFormatter(new InetAddressFormatter());
registry.addFormatter(new IsoOffsetFormatter());
}
19
Source : ApplicationConversionService.java
with Apache License 2.0
from hello-shf
with Apache License 2.0
from hello-shf
/**
* Configure the given {@link FormatterRegistry} with formatters and converters
* appropriate for most Spring Boot applications.
*
* @param registry the registry of converters to add to (must also be castable to
* ConversionService, e.g. being a {@link ConfigurableConversionService})
* @throws ClreplacedCastException if the given FormatterRegistry could not be cast to a
* ConversionService
*/
public static void configure(FormatterRegistry registry) {
DefaultConversionService.addDefaultConverters(registry);
DefaultFormattingConversionService.addDefaultFormatters(registry);
addApplicationFormatters(registry);
addApplicationConverters(registry);
}
19
Source : MVCConf.java
with BSD 3-Clause "New" or "Revised" License
from hdhong
with BSD 3-Clause "New" or "Revised" License
from hdhong
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
registry.addFormatter(new DateFormatter("yyyy-MM-dd"));
}
19
Source : Yt4jWebConfig.java
with GNU General Public License v3.0
from Gyv12345
with GNU General Public License v3.0
from Gyv12345
/**
* 增加GET请求参数中时间类型转换
* <ul>
* <li>HH:mm:ss -> LocalTime</li>
* <li>yyyy-MM-dd -> LocalDate</li>
* <li>yyyy-MM-dd HH:mm:ss -> LocalDateTime</li>
* </ul>
* @param registry
*/
@Override
public void addFormatters(FormatterRegistry registry) {
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
registrar.setTimeFormatter(DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN));
registrar.setDateFormatter(DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN));
registrar.setDateTimeFormatter(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
registrar.registerFormatters(registry);
}
19
Source : MvcConfig.java
with MIT License
from gexiangdong
with MIT License
from gexiangdong
@Override
public void addFormatters(final FormatterRegistry registry) {
logger.trace("addFormatters");
// 这里设置的 DateFormatter 会影响到向controller提交的日期的格式
// thymeleaf 中用 {{ }}写的日期的转换格式
// 这里设置的比在pojo里的@DateTimeFormat 优先级高
// 这里设置和在 application.yml 中 spring.mvc.date-format 一样的效果
// 建议不用
// 也可设置其他类型的转换器;包含自定义类型
// registry.addFormatter(new DateFormatter());
}
19
Source : WebMvcConfig.java
with Apache License 2.0
from Frodez
with Apache License 2.0
from Frodez
/**
* 配置格式化器
* @author Frodez
* @date 2019-05-10
*/
@Override
public void addFormatters(FormatterRegistry registry) {
// 对字符串进行转义
registry.addConverter(new Converter<String, String>() {
private final Escaper escaper = HtmlEscapers.htmlEscaper();
@Override
public String convert(String source) {
return escaper.escape(source);
}
});
}
19
Source : Application.java
with Apache License 2.0
from emeraldpay
with Apache License 2.0
from emeraldpay
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(byte[].clreplaced, String.clreplaced, Hex::encodeHexString);
}
19
Source : SpringletsEntityFormatWebConfiguration.java
with Apache License 2.0
from DISID
with Apache License 2.0
from DISID
@Override
public void addFormatters(FormatterRegistry registry) {
super.addFormatters(registry);
EnreplacedyFormatAnnotationFormatterFactory factory = new EnreplacedyFormatAnnotationFormatterFactory(messageSource, applicationContext, (FormattingConversionService) registry);
registry.addFormatterForFieldAnnotation(factory);
registry.addConverter(factory.getToStringConverter());
registry.addConverter(new EnumToMessageConverter(messageSource));
}
19
Source : SpringMvcConfig.java
with Apache License 2.0
from dibo-software
with Apache License 2.0
from dibo-software
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new DateConverter());
}
19
Source : SpringMvcConfig.java
with Apache License 2.0
from dibo-software
with Apache License 2.0
from dibo-software
/**
* String-Date类型转换
* @param registry
*/
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new DateConverter());
}
19
Source : SpringWebConfig.java
with Apache License 2.0
from dibo-software
with Apache License 2.0
from dibo-software
/**
* 默认支持String-Date类型转换
*
* @param registry
*/
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new DateConverter());
}
See More Examples