org.springframework.format.datetime.DateFormatter Java Examples

The following examples show how to use org.springframework.format.datetime.DateFormatter. 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
Source File: MVCConf.java    From springboot-plus with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@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 File: ThymeleafConfig.java    From taoshop with Apache License 2.0 4 votes vote down vote up
@Bean
public DateFormatter dateFormatter(){
    return new MyDateFormatter();
}
 
Example #3
Source File: WebConfig.java    From pizzeria with 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
Source File: BeanDefinitionDtoConverterServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
@PostConstruct
public void postConstruct() {
	DateFormatter dateFormatter = new DateFormatter();
	dateFormatter.setPattern("yyyy-MM-dd");
	conversionService.addFormatterForFieldType(Date.class, dateFormatter);
}
 
Example #5
Source File: Changelog.java    From spring-data-dev-tools with 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();
}