Search in sources :

Example 1 with DateColumn

use of tech.tablesaw.api.DateColumn 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 2 with DateColumn

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

the class DateMapFunctions method plus.

default DateColumn plus(int value, ChronoUnit unit) {
    DateColumn newColumn = DateColumn.create(dateColumnName(this, value, unit));
    DateColumn column1 = (DateColumn) this;
    for (int r = 0; r < column1.size(); r++) {
        int packedDate = column1.getIntInternal(r);
        if (packedDate == DateColumnType.missingValueIndicator()) {
            newColumn.appendMissing();
        } else {
            newColumn.appendInternal(PackedLocalDate.plus(value, unit, packedDate));
        }
    }
    return newColumn;
}
Also used : DateColumn(tech.tablesaw.api.DateColumn)

Example 3 with DateColumn

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

the class DateTimeMapFunctions method date.

/**
 * Returns a DateColumn containing the date portion of each dateTime in this DateTimeColumn
 */
default DateColumn date() {
    DateColumn newColumn = DateColumn.create(this.name() + " date");
    for (int r = 0; r < this.size(); r++) {
        if (isMissing(r)) {
            newColumn.appendMissing();
        } else {
            long c1 = getLongInternal(r);
            newColumn.appendInternal(PackedLocalDateTime.date(c1));
        }
    }
    return newColumn;
}
Also used : DateColumn(tech.tablesaw.api.DateColumn)

Aggregations

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