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

io.deephaven.engine.table.impl.sources.LongAsZonedDateTimeColumnSource Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
/**
 * 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.ZoneId;
import java.time.ZonedDateTime;

/**
 * Reinterpret result {@link ColumnSource} implementations that translates {@code long} to {@link ZonedDateTime} values.
 */
public class LongAsZonedDateTimeColumnSource
        extends LongAsTimeSource
        implements ConvertibleTimeSource.Zoned {
    private final ZoneId zone;

    public LongAsZonedDateTimeColumnSource(ColumnSource alternateColumnSource, ZoneId zone) {
        super(ZonedDateTime.class, alternateColumnSource);
        this.zone = zone;
    }

    @Override
    protected ZonedDateTime makeValue(long val) {
        return DateTimeUtils.epochNanosToZonedDateTime(val, zone);
    }

    @Override
    public ZoneId getZone() {
        return zone;
    }

    @Override
    public ColumnSource toZonedDateTime(@NotNull final ZoneId timeZone) {
        return zone.equals(timeZone) ? this : super.toZonedDateTime(timeZone);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy