本文整理汇总了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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}