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


Java DateFormatter类代码示例

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


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

示例1: CoreMappingEvaluationContext

import org.springframework.format.datetime.DateFormatter; //导入依赖的package包/类
public CoreMappingEvaluationContext(Object root) {
	super(root);
	try {
		// Add functions for use in the mapping expressions.
		registerFunction("substring", StringUtils.class.getMethod("substring", String.class, int.class, int.class));
		registerFunction("upperCase", StringUtils.class.getMethod("upperCase", String.class));
		registerFunction("leftPad", StringUtils.class.getMethod("leftPad", String.class, int.class, String.class));
		registerFunction("rightPad", StringUtils.class.getMethod("rightPad", String.class, int.class, String.class));
		registerFunction("trim", StringUtils.class.getMethod("trim", String.class));
		registerFunction("capitalize", WordUtils.class.getMethod("capitalizeFully", String.class));
		registerFunction("isBlank", StringUtils.class.getMethod("isBlank", CharSequence.class));
		registerFunction("split", StringUtils.class.getMethod("split", String.class, char.class));
		registerFunction("join", StringUtils.class.getMethod("join", Object[].class, char.class));
		registerFunction("toBoolean", BooleanUtils.class.getMethod("toBoolean", String.class));

		DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
		conversionService.addFormatterForFieldType(Date.class, new DateFormatter("MM/dd/yyyy"));
		setTypeConverter(new StandardTypeConverter(conversionService));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:SmarterApp,项目名称:TechnologyReadinessTool,代码行数:23,代码来源:CoreMappingEvaluationContext.java

示例2: mvcConversionService

import org.springframework.format.datetime.DateFormatter; //导入依赖的package包/类
@Bean
public FormattingConversionService mvcConversionService() { // Método para setar padrões de conversão
    DefaultFormattingConversionService conversionService
            = new DefaultFormattingConversionService(
                    true);

    DateFormatterRegistrar registrar = new DateFormatterRegistrar();
    registrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
    registrar.registerFormatters(conversionService);
    return conversionService;
}
 
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:12,代码来源:AppWebConfiguration.java

示例3: addFormatters

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

示例4: mvcConversionService

import org.springframework.format.datetime.DateFormatter; //导入依赖的package包/类
@Bean
public FormattingConversionService mvcConversionService() {
	DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false);
	addFormattersForFieldAnnotation(conversionService);
	DateFormatterRegistrar registrar = new DateFormatterRegistrar();
	registrar.setFormatter(new DateFormatter(GLOBAL_DATE_FORMAT));
	registrar.registerFormatters(conversionService);
	return conversionService;
}
 
开发者ID:fernaspiazu,项目名称:recruiting-old-style,代码行数:10,代码来源:WebApplicationConfig.java

示例5: dateFormatter

import org.springframework.format.datetime.DateFormatter; //导入依赖的package包/类
@Bean
@ConditionalOnProperty(prefix = "spring.mvc", name = "date-format")
public Formatter<Date> dateFormatter() {
	return new DateFormatter(this.mvcProperties.getDateFormat());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:WebMvcAutoConfiguration.java

示例6: addFormatters

import org.springframework.format.datetime.DateFormatter; //导入依赖的package包/类
@Override
public void addFormatters(FormatterRegistry registry) {
	DateFormatter dateFormatter = new DateFormatter(DateUtils.FORMAT_LOCAL);
	registry.addFormatter(dateFormatter);
}
 
开发者ID:pablogrela,项目名称:members_cuacfm,代码行数:6,代码来源:WebMvcConfig.java

示例7: postConstruct

import org.springframework.format.datetime.DateFormatter; //导入依赖的package包/类
@PostConstruct
public void postConstruct() {
	DateFormatter dateFormatter = new DateFormatter();
	dateFormatter.setPattern("yyyy-MM-dd");
	conversionService.addFormatterForFieldType(Date.class, dateFormatter);
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:7,代码来源:BeanDefinitionDtoConverterServiceImpl.java

示例8: toString

import org.springframework.format.datetime.DateFormatter; //导入依赖的package包/类
@Override
public String toString() {

	ArtifactVersion version = ArtifactVersion.of(module);

	String headline = String.format("Changes in version %s (%s)", version,
			new DateFormatter("YYYY-MM-dd").print(new Date(), Locale.US));

	StringBuilder builder = new StringBuilder(headline).append(OsUtils.LINE_SEPARATOR);

	for (int i = 0; i < headline.length(); i++) {
		builder.append("-");
	}

	builder.append(OsUtils.LINE_SEPARATOR);

	for (Ticket ticket : tickets) {

		String summary = ticket.getSummary();

		builder.append("* ").append(ticket.getId()).append(" - ").append(summary.trim());

		if (!summary.endsWith(".")) {
			builder.append(".");
		}

		builder.append(OsUtils.LINE_SEPARATOR);
	}

	return builder.toString();
}
 
开发者ID:spring-projects,项目名称:spring-data-dev-tools,代码行数:32,代码来源:Changelog.java


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