本文整理匯總了Java中org.springframework.format.FormatterRegistry.addFormatterForFieldAnnotation方法的典型用法代碼示例。如果您正苦於以下問題:Java FormatterRegistry.addFormatterForFieldAnnotation方法的具體用法?Java FormatterRegistry.addFormatterForFieldAnnotation怎麽用?Java FormatterRegistry.addFormatterForFieldAnnotation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.format.FormatterRegistry
的用法示例。
在下文中一共展示了FormatterRegistry.addFormatterForFieldAnnotation方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void registerFormatters(FormatterRegistry registry) {
DateTimeConverters.registerConverters(registry);
DateTimeFormatter dateFormatter = getFormatter(Type.DATE);
DateTimeFormatter timeFormatter = getFormatter(Type.TIME);
DateTimeFormatter dateTimeFormatter = getFormatter(Type.DATE_TIME);
registry.addFormatterForFieldType(LocalDate.class,
new TemporalAccessorPrinter(dateFormatter),
new TemporalAccessorParser(LocalDate.class, dateFormatter));
registry.addFormatterForFieldType(LocalTime.class,
new TemporalAccessorPrinter(timeFormatter),
new TemporalAccessorParser(LocalTime.class, timeFormatter));
registry.addFormatterForFieldType(LocalDateTime.class,
new TemporalAccessorPrinter(dateTimeFormatter),
new TemporalAccessorParser(LocalDateTime.class, dateTimeFormatter));
registry.addFormatterForFieldType(ZonedDateTime.class,
new TemporalAccessorPrinter(dateTimeFormatter),
new TemporalAccessorParser(ZonedDateTime.class, dateTimeFormatter));
registry.addFormatterForFieldType(OffsetDateTime.class,
new TemporalAccessorPrinter(dateTimeFormatter),
new TemporalAccessorParser(OffsetDateTime.class, dateTimeFormatter));
registry.addFormatterForFieldType(OffsetTime.class,
new TemporalAccessorPrinter(timeFormatter),
new TemporalAccessorParser(OffsetTime.class, timeFormatter));
registry.addFormatterForFieldType(Instant.class, new InstantFormatter());
registry.addFormatterForFieldAnnotation(new Jsr310DateTimeFormatAnnotationFormatterFactory());
}
示例2: addDefaultFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
/**
* Add formatters appropriate for most environments, including number formatters and a Joda-Time
* date formatter if Joda-Time is present on the classpath.
* @param formatterRegistry the service to register default formatters against
*/
public static void addDefaultFormatters(FormatterRegistry formatterRegistry) {
formatterRegistry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
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);
}
}
示例3: 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);
}
}
示例4: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@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.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
}
示例5: 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);
}
}
示例6: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
LongDateTimeFormatAnnotationFormatterFactory longDateFactory =
new LongDateTimeFormatAnnotationFormatterFactory();
registry.addFormatterForFieldAnnotation(longDateFactory);
super.addFormatters(registry);
}
示例7: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void registerFormatters(FormatterRegistry registry) {
DateTimeConverters.registerConverters(registry);
DateTimeFormatter dateFormatter = getFormatter(Type.DATE);
DateTimeFormatter timeFormatter = getFormatter(Type.TIME);
DateTimeFormatter dateTimeFormatter = getFormatter(Type.DATE_TIME);
registry.addFormatterForFieldType(LocalDate.class,
new TemporalAccessorPrinter(dateFormatter),
new TemporalAccessorParser(LocalDate.class, dateFormatter));
registry.addFormatterForFieldType(LocalTime.class,
new TemporalAccessorPrinter(timeFormatter),
new TemporalAccessorParser(LocalTime.class, timeFormatter));
registry.addFormatterForFieldType(LocalDateTime.class,
new TemporalAccessorPrinter(dateTimeFormatter),
new TemporalAccessorParser(LocalDateTime.class, dateTimeFormatter));
registry.addFormatterForFieldType(ZonedDateTime.class,
new TemporalAccessorPrinter(dateTimeFormatter),
new TemporalAccessorParser(ZonedDateTime.class, dateTimeFormatter));
registry.addFormatterForFieldType(OffsetDateTime.class,
new TemporalAccessorPrinter(dateTimeFormatter),
new TemporalAccessorParser(OffsetDateTime.class, dateTimeFormatter));
registry.addFormatterForFieldType(OffsetTime.class,
new TemporalAccessorPrinter(timeFormatter),
new TemporalAccessorParser(OffsetTime.class, timeFormatter));
registry.addFormatterForFieldType(Instant.class, new InstantFormatter());
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 Jsr310DateTimeFormatAnnotationFormatterFactory());
}
示例8: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
super.addFormatters(registry);
EntityFormatAnnotationFormatterFactory factory = new EntityFormatAnnotationFormatterFactory(
messageSource, applicationContext, (FormattingConversionService) registry);
registry.addFormatterForFieldAnnotation(factory);
registry.addConverter(factory.getToStringConverter());
registry.addConverter(new EnumToMessageConverter(messageSource));
}
示例9: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(final FormatterRegistry registry) {
if(converters != null) {
for(final Converter<?, ?> converter : converters) {
registry.addConverter(converter);
}
}
registry.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
}
示例10: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void registerFormatters(FormatterRegistry registry) {
for (Object f : formatters) {
if (f instanceof FormatterRegistrar) {
FormatterRegistrar registrar = (FormatterRegistrar) f;
registrar.registerFormatters(registry);
}
if (f instanceof AnnotationFormatterFactory) {
AnnotationFormatterFactory<?> factory = (AnnotationFormatterFactory<?>) f;
registry.addFormatterForFieldAnnotation(factory);
}
}
}
示例11: addDefaultFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
/**
* Add formatters appropriate for most environments, including number formatters and a Joda-Time
* date formatter if Joda-Time is present on the classpath.
* @param formatterRegistry the service to register default formatters against
*/
public static void addDefaultFormatters(FormatterRegistry formatterRegistry) {
formatterRegistry.addFormatterForFieldAnnotation(new NumberFormatAnnotationFormatterFactory());
if (jodaTimePresent) {
new JodaTimeFormatterRegistrar().registerFormatters(formatterRegistry);
}
else {
new DateFormatterRegistrar().registerFormatters(formatterRegistry);
}
}
示例12: registerFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
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 DateTimeParser(dateFormatter),
LocalDate.class);
addFormatterForFields(registry,
new ReadablePartialPrinter(timeFormatter),
new DateTimeParser(timeFormatter),
LocalTime.class);
addFormatterForFields(registry,
new ReadablePartialPrinter(dateTimeFormatter),
new DateTimeParser(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.addFormatterForFieldAnnotation(new JodaDateTimeFormatAnnotationFormatterFactory());
}
示例13: 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);
}
}
示例14: addFormatters
import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addFormatterForFieldType(String.class, new StringTrimmingFormatter());
registry.addFormatterForFieldAnnotation(new DateTimeWithZoneFormatterFactory());
registry.addFormatterForFieldAnnotation(new LawJournalEntryCodeFormatterFactory(lawJournalEntryCodeExtractor));
registry.addFormatterForFieldAnnotation(new MultiWordFormatterFactory());
}
示例15: 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);
}