本文整理匯總了Java中org.springframework.format.FormatterRegistry.addFormatter方法的典型用法代碼示例。如果您正苦於以下問題:Java FormatterRegistry.addFormatter方法的具體用法?Java FormatterRegistry.addFormatter怎麽用?Java FormatterRegistry.addFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.format.FormatterRegistry
的用法示例。
在下文中一共展示了FormatterRegistry.addFormatter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addDefaultFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
/**
* 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);
}
}
示例2: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
super.addFormatters(registry);
registry.addConverter(new YesNoStatusConverter());
registry.addConverter(new EnableDisableStatusConverter());
registry.addConverter(new ResourceTypeConverter());
DateFormatter dateFormatter = new DateFormatter("yyyy-MM-dd HH:mm:ss");
dateFormatter.setLenient(true);
registry.addFormatter(dateFormatter);
}
示例3: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@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);
}
}
示例4: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(DistanceFormatter.INSTANCE);
registry.addFormatter(PointFormatter.INSTANCE);
if (!(registry instanceof FormattingConversionService)) {
return;
}
FormattingConversionService conversionService = (FormattingConversionService) registry;
DomainClassConverter<FormattingConversionService> converter = new DomainClassConverter<FormattingConversionService>(conversionService);
converter.setApplicationContext(context);
}
示例5: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
super.addFormatters(registry);
registry.addFormatter(new SelectionOptionFormatter());
registry.addFormatter(new TimeFormatter());
registry.addFormatter(new DateFormatter());
registry.addFormatter(new TimestampFormatter());
}
示例6: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
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);
}
}
示例7: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatterForFieldAnnotation(new NonEmptyStringAnnotationFormatterFactory());
registry.addFormatter(messageSourceDateFormatter());
registry.addConverter(new EnumConverter(configureMessageSource()));
// registry.addConverter(new StringTrimmerConverter(true));
super.addFormatters(registry);
}
示例8: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(final FormatterRegistry registry) {
super.addFormatters(registry);
registry.addFormatter(varietyFormatter());
registry.addFormatter(dateFormatter());
}
示例9: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void registerFormatters(FormatterRegistry registry) {
registry.addFormatter(new TestBeanFormatter());
}
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:5,代碼來源:FormattingConversionServiceFactoryBeanTests.java
示例10: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(new TcDateFormatter());
super.addFormatters(registry);
}
示例11: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(localDateFormatter);
registry.addFormatter(localDateTimeFormatter);
}
示例12: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
DateFormatter dateFormatter = new DateFormatter(DateUtils.FORMAT_LOCAL);
registry.addFormatter(dateFormatter);
}
示例13: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry formatterRegistry) {
formatterRegistry.addFormatter(petTypeFormatter());
}
示例14: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(new StringTrimFormatter());
}
示例15: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatter(new DateFormatter());
}