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

com.tecacet.util.conversion.LocalDateToStringConverter Maven / Gradle / Ivy

Go to download

JFlat's purpose is to convert flat files to Java Beans and vice versa. Some supported formats are CSV, fixed-width, arbitrary delimiters, and excel files. There are also tools to generate Java Beans to/from JDBC and Swing tables. JFlat is highly extensible and can be adopted to support additional formats.

The newest version!
package com.tecacet.util.conversion;

import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;

public class LocalDateToStringConverter implements ToStringConverter {

    private static final String DEFAULT_DATE_PATTERN = "dd-MM-yyyy";

    private String dateFormat;
    
    public LocalDateToStringConverter(String dateFormat) {
        this.dateFormat = dateFormat;
    }
    
    public LocalDateToStringConverter() {
        this(DEFAULT_DATE_PATTERN);
    }
    
    @Override
    public String convert(LocalDate value) {
        if (value == null) {
            return null;
        }
        return value.toString(DateTimeFormat.forPattern(dateFormat));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy