Example usage for org.joda.time ReadableInstant getZone

List of usage examples for org.joda.time ReadableInstant getZone

Introduction

In this page you can find the example usage for org.joda.time ReadableInstant getZone.

Prototype

DateTimeZone getZone();

Source Link

Document

Gets the time zone of the instant from the chronology.

Usage

From source file:io.coala.time.Instant.java

License:Apache License

/** @return the Joda {@link ReadableInstant} implementation of an instant */
public DateTime toDate(final ReadableInstant offset) {
    return new DateTime(offset.getMillis() + toMillisLong(), offset.getZone());
}

From source file:org.apache.beam.sdk.extensions.sql.impl.interpreter.operator.date.BeamSqlDateCeilExpression.java

License:Apache License

@Override
public BeamSqlPrimitive evaluate(Row inputRow, BoundedWindow window,
        ImmutableMap<Integer, Object> correlateEnv) {
    ReadableInstant date = opValueEvaluated(0, inputRow, window, correlateEnv);
    long time = date.getMillis();
    TimeUnitRange unit = ((BeamSqlPrimitive<TimeUnitRange>) op(1)).getValue();

    long newTime = DateTimeUtils.unixTimestampCeil(unit, time);
    DateTime newDate = new DateTime(newTime, date.getZone());

    return BeamSqlPrimitive.of(outputType, newDate);
}

From source file:org.apache.beam.sdk.extensions.sql.impl.interpreter.operator.date.BeamSqlDateFloorExpression.java

License:Apache License

@Override
public BeamSqlPrimitive evaluate(Row inputRow, BoundedWindow window,
        ImmutableMap<Integer, Object> correlateEnv) {
    ReadableInstant date = opValueEvaluated(0, inputRow, window, correlateEnv);
    long time = date.getMillis();
    TimeUnitRange unit = ((BeamSqlPrimitive<TimeUnitRange>) op(1)).getValue();

    long newTime = DateTimeUtils.unixTimestampFloor(unit, time);

    DateTime newDate = new DateTime(newTime, date.getZone());
    return BeamSqlPrimitive.of(outputType, newDate);
}

From source file:org.apache.beam.sdk.values.Row.java

License:Apache License

/**
 * Get a {@link TypeName#DATETIME} value by field index, {@link IllegalStateException} is thrown
 * if schema doesn't match.//www.j a va 2  s. c o m
 */
@Nullable
public ReadableDateTime getDateTime(int idx) {
    ReadableInstant instant = getValue(idx);
    return instant == null ? null : new DateTime(instant).withZone(instant.getZone());
}

From source file:org.jadira.usertype.dateandtime.joda.util.DateTimeZoneWithOffset.java

License:Apache License

public DateTimeZoneWithOffset(ReadableInstant instant) {
    this(instant.getZone(), DateTimeZone.forOffsetMillis(instant.getZone().getOffset(instant)));
}