
com.gh.mygreen.xlsmapper.cellconverter.impl.SqlTimestampCellConverterFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xlsmapper Show documentation
Show all versions of xlsmapper Show documentation
XlsMapper is Java Library for mapping Excel sheets to POJO.
The newest version!
package com.gh.mygreen.xlsmapper.cellconverter.impl;
import java.sql.Timestamp;
import java.util.Date;
import com.gh.mygreen.xlsmapper.Configuration;
import com.gh.mygreen.xlsmapper.cellconverter.CellConverter;
import com.gh.mygreen.xlsmapper.fieldaccessor.FieldAccessor;
/**
* {@link Timestamp}を処理する{@link CellConverter}を作成するためのファクトリクラス。
* @since 2.0
* @author T.TSUCHIE
*
*/
public class SqlTimestampCellConverterFactory extends AbstractDateCellConverterFactory {
@Override
public SqlTimestampCellConverter create(FieldAccessor field, Configuration config) {
final SqlTimestampCellConverter cellConverter = new SqlTimestampCellConverter(field, config, this);
setupCellConverter(cellConverter, field, config);
return cellConverter;
}
@Override
protected Timestamp convertTypeValue(Date date) {
return new Timestamp(date.getTime());
}
/**
* {@inheritDoc}
* {@code yyyy-MM-dd HH:mm:ss.SSS}の値を返す。
*/
@Override
protected String getDefaultJavaPattern() {
return "yyyy-MM-dd HH:mm:ss.SSS";
}
/**
* {@inheritDoc}
* {@code yyyy-mm-dd hh:mm:ss.SSS}の値を返す。
*/
@Override
protected String getDefaultExcelPattern() {
return "yyyy-mm-dd hh:mm:ss.SSS";
}
public class SqlTimestampCellConverter extends AbstractDateCellConverter {
private final SqlTimestampCellConverterFactory convererFactory;
private SqlTimestampCellConverter(final FieldAccessor field, final Configuration config,
final SqlTimestampCellConverterFactory convererFactory) {
super(field, config);
this.convererFactory = convererFactory;
}
@Override
protected Timestamp convertTypeValue(final Date value) {
return convererFactory.convertTypeValue(value);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy