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

com.datastax.data.exploration.biz.datatable.column.DateTimeColumn Maven / Gradle / Ivy

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 HH:mm:ss
 */
public class DateTimeColumn extends TimestampColumn {

    public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public DateTimeColumn(String columnName) {
        super(columnName, DataType.DATE_TIME);
    }

    @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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy