io.geewit.web.convert.converter.DateConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gw-web-converter Show documentation
Show all versions of gw-web-converter Show documentation
A Java Utils Libraray By Geewit
The newest version!
package io.geewit.web.convert.converter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter;
import java.text.ParseException;
import java.util.Date;
/**
* @author geewit
*/
public class DateConverter implements Converter {
private final static Logger logger = LoggerFactory.getLogger(DateConverter.class);
private static final String[] PATTERNS = {"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", "HH:mm:ss"};
@Override
public Date convert(String source) {
try {
return org.apache.commons.lang3.time.DateUtils.parseDateStrictly(source, PATTERNS);
} catch (ParseException e) {
logger.warn(e.getMessage());
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy