Search in sources :

Example 1 with DateTimeColumn

use of tech.tablesaw.api.DateTimeColumn in project symja_android_library by axkr.

the class DateMapFunctions method atTime.

/**
 * Returns a DateTime column where each value consists of the dates from this column combined with
 * the corresponding times from the other column
 */
default DateTimeColumn atTime(TimeColumn timeColumn) {
    DateTimeColumn newColumn = DateTimeColumn.create(this.name() + " " + timeColumn.name());
    for (int r = 0; r < this.size(); r++) {
        int c1 = this.getIntInternal(r);
        int c2 = timeColumn.getIntInternal(r);
        if (valueIsMissing(c1) || valueIsMissing(c2)) {
            newColumn.appendMissing();
        } else {
            newColumn.appendInternal(PackedLocalDateTime.create(c1, c2));
        }
    }
    return newColumn;
}
Also used : DateTimeColumn(tech.tablesaw.api.DateTimeColumn)

Example 2 with DateTimeColumn

use of tech.tablesaw.api.DateTimeColumn in project symja_android_library by axkr.

the class DateTimeMapFunctions method lead.

@Override
default DateTimeColumn lead(int n) {
    DateTimeColumn column = lag(-n);
    column.setName(name() + " lead(" + n + ")");
    return column;
}
Also used : DateTimeColumn(tech.tablesaw.api.DateTimeColumn)

Example 3 with DateTimeColumn

use of tech.tablesaw.api.DateTimeColumn in project symja_android_library by axkr.

the class CsvWriter method writeValues.

private void writeValues(Table table, CsvWriteOptions options, int r, String[] entries, int c) {
    DateTimeFormatter dateFormatter = options.dateFormatter();
    DateTimeFormatter dateTimeFormatter = options.dateTimeFormatter();
    ColumnType columnType = table.column(c).type();
    if (dateFormatter != null && columnType.equals(ColumnType.LOCAL_DATE)) {
        DateColumn dc = (DateColumn) table.column(c);
        entries[c] = options.dateFormatter().format(dc.get(r));
    } else if (dateTimeFormatter != null && columnType.equals(ColumnType.LOCAL_DATE_TIME)) {
        DateTimeColumn dc = (DateTimeColumn) table.column(c);
        entries[c] = options.dateTimeFormatter().format(dc.get(r));
    } else {
        if (options.usePrintFormatters()) {
            entries[c] = table.getString(r, c);
        } else {
            entries[c] = table.getUnformatted(r, c);
        }
    }
}
Also used : ColumnType(tech.tablesaw.api.ColumnType) DateColumn(tech.tablesaw.api.DateColumn) DateTimeFormatter(java.time.format.DateTimeFormatter) DateTimeColumn(tech.tablesaw.api.DateTimeColumn)

Example 4 with DateTimeColumn

use of tech.tablesaw.api.DateTimeColumn in project symja_android_library by axkr.

the class DateMapFunctions method atTime.

/**
 * Returns a DateTime column where each value consists of the dates from this column combined with
 * the corresponding times from the other column
 */
default DateTimeColumn atTime(LocalTime time) {
    Preconditions.checkNotNull(time);
    DateTimeColumn newColumn = DateTimeColumn.create(this.name() + " " + time.toString());
    for (int r = 0; r < this.size(); r++) {
        int c1 = this.getIntInternal(r);
        if (valueIsMissing(c1)) {
            newColumn.appendMissing();
        } else {
            LocalDate value1 = PackedLocalDate.asLocalDate(c1);
            newColumn.appendInternal(PackedLocalDateTime.pack(value1, time));
        }
    }
    return newColumn;
}
Also used : DateTimeColumn(tech.tablesaw.api.DateTimeColumn) LocalDate(java.time.LocalDate)

Aggregations

DateTimeColumn (tech.tablesaw.api.DateTimeColumn)4 LocalDate (java.time.LocalDate)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ColumnType (tech.tablesaw.api.ColumnType)1 DateColumn (tech.tablesaw.api.DateColumn)1