当前位置: 首页>>代码示例>>Java>>正文


Java DateTimeFormatterRegistrar类代码示例

本文整理汇总了Java中org.springframework.format.datetime.standard.DateTimeFormatterRegistrar的典型用法代码示例。如果您正苦于以下问题:Java DateTimeFormatterRegistrar类的具体用法?Java DateTimeFormatterRegistrar怎么用?Java DateTimeFormatterRegistrar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DateTimeFormatterRegistrar类属于org.springframework.format.datetime.standard包,在下文中一共展示了DateTimeFormatterRegistrar类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addDefaultFormatters

import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; //导入依赖的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

示例2: addDefaultFormatters

import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; //导入依赖的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

示例3: createFormattingConversionService

import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; //导入依赖的package包/类
/**
 * Create a FormattingConversionService which use ISO date format, instead of the localized one.
 * @return the FormattingConversionService
 */
public static FormattingConversionService createFormattingConversionService() {
    DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService ();
    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setUseIsoFormat(true);
    registrar.registerFormatters(dfcs);
    return dfcs;
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:12,代码来源:TestUtil.java

示例4: localDateFeignFormatterRegistrar

import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; //导入依赖的package包/类
/**
 * Bugfix for Feign not knowing how to handle @DateTimeFormat in query parameters
 *
 * see https://github.com/spring-cloud/spring-cloud-netflix/issues/1178
 */
@Bean
public FeignFormatterRegistrar localDateFeignFormatterRegistrar() {
    return formatterRegistry -> {
        DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
        registrar.setUseIsoFormat(true);
        registrar.registerFormatters(formatterRegistry);
    };
}
 
开发者ID:ElderByte-,项目名称:spring-cloud-starter-bootstrap,代码行数:14,代码来源:DefaultFeignConfiguration.java

示例5: addFormatters

import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar; //导入依赖的package包/类
@Override
public void addFormatters(FormatterRegistry registry) {
    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setUseIsoFormat(true);
    registrar.registerFormatters(registry);
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:7,代码来源:DateTimeFormatConfiguration.java


注:本文中的org.springframework.format.datetime.standard.DateTimeFormatterRegistrar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。