Java Code Examples for org.springframework.format.datetime.DateFormatter

The following examples show how to use org.springframework.format.datetime.DateFormatter. These examples are extracted from open source projects. 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
@Override
public void addFormatters(FormatterRegistry registry) {
    registry.addFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
    registry.addFormatter(new DateFormatter("yyyy-MM-dd"));
}
 
Example 2
Source Project: taoshop   Source File: ThymeleafConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public DateFormatter dateFormatter(){
    return new MyDateFormatter();
}
 
Example 3
Source Project: pizzeria   Source File: WebConfig.java    License: MIT License 4 votes vote down vote up
@Override
public void addFormatters(FormatterRegistry registry) {
    DateFormatter dateFormatter = new DateFormatter();
    dateFormatter.setStyle(DateFormat.MEDIUM);
    registry.addFormatter(dateFormatter);
}
 
Example 4
@PostConstruct
public void postConstruct() {
	DateFormatter dateFormatter = new DateFormatter();
	dateFormatter.setPattern("yyyy-MM-dd");
	conversionService.addFormatterForFieldType(Date.class, dateFormatter);
}
 
Example 5
Source Project: spring-data-dev-tools   Source File: Changelog.java    License: Apache License 2.0 3 votes vote down vote up
@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(IOUtils.LINE_SEPARATOR);

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

	builder.append(IOUtils.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(IOUtils.LINE_SEPARATOR);
	}

	return builder.toString();
}