io.deephaven.engine.table.impl.sources.LongAsLocalTimeColumnSource 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.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
/**
* Reinterpret result {@link ColumnSource} implementations that translates {@code long} to {@link LocalTime} values.
*/
public class LongAsLocalTimeColumnSource extends LongAsTimeSource {
private final ZoneId zone;
public LongAsLocalTimeColumnSource(ColumnSource alternateColumnSource, ZoneId zone) {
super(LocalTime.class, alternateColumnSource);
this.zone = zone;
}
@Override
protected LocalTime makeValue(long val) {
final ZonedDateTime zdt = DateTimeUtils.epochNanosToZonedDateTime(val, zone);
return zdt == null ? null : zdt.toLocalTime();
}
@Override
public ColumnSource toLocalTime(@NotNull final ZoneId timeZone) {
return zone.equals(timeZone) ? this : super.toLocalTime(timeZone);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy