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


Java FormatterRegistry.addFormatter方法代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:32,代碼來源:DefaultFormattingConversionService.java

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

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

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

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

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

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

示例8: addFormatters

import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(final FormatterRegistry registry) {
    super.addFormatters(registry);
    registry.addFormatter(varietyFormatter());
    registry.addFormatter(dateFormatter());
}
 
開發者ID:dctproject,項目名稱:seed,代碼行數:7,代碼來源:SpringWebConfig.java

示例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);
}
 
開發者ID:srarcbrsent,項目名稱:tc,代碼行數:6,代碼來源:TcStubController.java

示例11: addFormatters

import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
    registry.addFormatter(localDateFormatter);
    registry.addFormatter(localDateTimeFormatter);
}
 
開發者ID:mattpwest,項目名稱:entelect-spring-webapp-template,代碼行數:6,代碼來源:SpringMVCConfig.java

示例12: addFormatters

import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
	DateFormatter dateFormatter = new DateFormatter(DateUtils.FORMAT_LOCAL);
	registry.addFormatter(dateFormatter);
}
 
開發者ID:pablogrela,項目名稱:members_cuacfm,代碼行數:6,代碼來源:WebMvcConfig.java

示例13: addFormatters

import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry formatterRegistry) {
	formatterRegistry.addFormatter(petTypeFormatter());
}
 
開發者ID:YoannBuch,項目名稱:DependencyInjectionAgent,代碼行數:5,代碼來源:MvcCoreConfig.java

示例14: addFormatters

import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
	registry.addFormatter(new StringTrimFormatter());
}
 
開發者ID:u2ware,項目名稱:springfield,代碼行數:5,代碼來源:WebmvcConfiguration.java

示例15: addFormatters

import org.springframework.format.FormatterRegistry; //導入方法依賴的package包/類
@Override
public void addFormatters(FormatterRegistry registry) {
    registry.addFormatter(new DateFormatter());
}
 
開發者ID:mikehartley,項目名稱:yottr,代碼行數:5,代碼來源:AppConfig.java


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