com.supwisdom.spreadsheet.mapper.o2w.converter.LocalDatePropertyStringifier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spreadsheet-mapper-java8 Show documentation
Show all versions of spreadsheet-mapper-java8 Show documentation
Spreadsheet Mapper - Java 8 support
package com.supwisdom.spreadsheet.mapper.o2w.converter;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* local date text value with supplied pattern converter
* Created by hanwen on 5/3/16.
*/
public class LocalDatePropertyStringifier extends PropertyStringifierTemplate {
private String pattern;
public LocalDatePropertyStringifier(String pattern) {
this.pattern = pattern;
}
@Override
public String convertProperty(Object property) {
if (!LocalDate.class.equals(property.getClass())) {
throw new IllegalArgumentException(
"Not a LocalDate: " + property.getClass().getName() + " value: " + property.toString());
}
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
return ((LocalDate) property).format(dateTimeFormatter);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy