org.springframework.format.number.NumberFormatAnnotationFormatterFactory Java Examples

The following examples show how to use org.springframework.format.number.NumberFormatAnnotationFormatterFactory. 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 vote down vote up
/**
 * 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 vote down vote up
/**
 * 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: DefaultFormattingConversionService.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #4
Source File: DefaultFormattingConversionService.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
	}
}