All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lockss.laaws.poller.config.LocalDateConverter Maven / Gradle / Ivy

package org.lockss.laaws.poller.config;

import org.springframework.core.convert.converter.Converter;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class LocalDateConverter implements Converter {
    private final DateTimeFormatter formatter;

    public LocalDateConverter(String dateFormat) {
        this.formatter = DateTimeFormatter.ofPattern(dateFormat);
    }

    @Override
    public LocalDate convert(String source) {
        if(source == null || source.isEmpty()) {
            return null;
        }
        return LocalDate.parse(source, this.formatter);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy