
org.sfm.csv.impl.cellreader.DateCellValueReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.
The newest version!
package org.sfm.csv.impl.cellreader;
import org.sfm.csv.CellValueReader;
import org.sfm.csv.impl.ParsingContext;
import org.sfm.csv.impl.ParsingException;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
public class DateCellValueReader implements CellValueReader {
private int index;
public DateCellValueReader(int index) {
this.index = index;
}
@Override
public Date read(char[] chars, int offset, int length, ParsingContext parsingContext) {
if (length == 0) return null;
String str = StringCellValueReader.readString(chars, offset, length);
try {
DateFormat df = parsingContext.getDateFormat(index);
return df.parse(str);
} catch (ParseException e) {
throw new ParsingException(e.getMessage());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy