當前位置: 首頁>>代碼示例>>Java>>正文


Java FormatterRegistry.addFormatterForFieldAnnotation方法代碼示例

本文整理匯總了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());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:37,代碼來源:DateTimeFormatterRegistrar.java

示例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);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:DefaultFormattingConversionService.java

示例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);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:32,代碼來源:DefaultFormattingConversionService.java

示例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());
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:40,代碼來源:JodaTimeFormatterRegistrar.java

示例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);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:DateFormatterRegistrar.java

示例6: addFormatters

import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
    LongDateTimeFormatAnnotationFormatterFactory longDateFactory =
            new LongDateTimeFormatAnnotationFormatterFactory();
    registry.addFormatterForFieldAnnotation(longDateFactory);
    super.addFormatters(registry);
}
 
開發者ID:pandboy,項目名稱:pingguopai,代碼行數:8,代碼來源:WebMvcConfigurer.java

示例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());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:41,代碼來源:DateTimeFormatterRegistrar.java

示例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));
}
 
開發者ID:DISID,項目名稱:springlets,代碼行數:11,代碼來源:SpringletsEntityFormatWebConfiguration.java

示例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());
}
 
開發者ID:hpe-idol,項目名稱:find,代碼行數:11,代碼來源:DispatcherServletConfiguration.java

示例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);
		}
	}
}
 
開發者ID:agwlvssainokuni,項目名稱:sqlapp,代碼行數:14,代碼來源:DelegateFormatterRegistrar.java

示例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);
	}
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:15,代碼來源:DefaultFormattingConversionService.java

示例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());
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:39,代碼來源:JodaTimeFormatterRegistrar.java

示例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);
	}
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:12,代碼來源:DateFormatterRegistrar.java

示例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());
}
 
開發者ID:CeON,項目名稱:saos,代碼行數:8,代碼來源:WebappConfiguration.java

示例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);
}
 
開發者ID:opensource21,項目名稱:fuwesta,代碼行數:9,代碼來源:WebMvcConfig.java


注:本文中的org.springframework.format.FormatterRegistry.addFormatterForFieldAnnotation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。