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

com.datastax.data.exploration.biz.datatable.column.TimeColumn 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;

/**
 * 时间型属性列
 * 格式:HH:mm:ss
 */
public class TimeColumn extends TimestampColumn {

    public static SimpleDateFormat format = new SimpleDateFormat("HH:mm");

    public TimeColumn(String columnName) {
        super(columnName, DataType.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