com.datastax.data.exploration.biz.datatable.column.DateColumn Maven / Gradle / Ivy
The newest version!
package com.datastax.data.exploration.biz.datatable.column;
import com.datastax.data.exploration.biz.datatable.DataType;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;
/**
* 日期属性列属性列
* 格式:yyyy-MM-dd
*/
public class DateColumn extends TimestampColumn {
public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
public DateColumn(String columnName) {
super(columnName, DataType.DATE);
}
@Override
Date transferValue(String str) {
try {
return format.parse(str);
} catch (Exception e) {
addError(ERROR_TYPE, str);
return null;
}
}
@Override
void flush() {
//
}
public Date max() {
return getNotNullValues().stream().max(Comparator.comparingLong(Date::getTime)).orElse(null);
}
public Date min() {
return getNotNullValues().stream().min(Comparator.comparingLong(Date::getTime)).orElse(null);
}
}