io.deephaven.engine.table.impl.sources.LongAsLocalDateColumnSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/**
* Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.engine.table.impl.sources;
import io.deephaven.engine.table.ColumnSource;
import io.deephaven.time.DateTimeUtils;
import org.jetbrains.annotations.NotNull;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
/**
* Reinterpret result {@link ColumnSource} implementations that translates {@code long} to {@link LocalDate} values.
*/
public class LongAsLocalDateColumnSource extends LongAsTimeSource {
private final ZoneId zone;
public LongAsLocalDateColumnSource(ColumnSource alternateColumnSource, ZoneId zone) {
super(LocalDate.class, alternateColumnSource);
this.zone = zone;
}
@Override
protected LocalDate makeValue(long val) {
final ZonedDateTime zdt = DateTimeUtils.epochNanosToZonedDateTime(val, zone);
return zdt == null ? null : zdt.toLocalDate();
}
@Override
public ColumnSource toLocalDate(@NotNull final ZoneId timeZone) {
return zone.equals(timeZone) ? this : super.toLocalDate(timeZone);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy