use of org.apache.hadoop.hive.common.type.TimestampTZ in project hive by apache.
the class JavaTimestampLocalTZObjectInspector method getPrimitiveWritableObject.
@Override
public TimestampLocalTZWritable getPrimitiveWritableObject(Object o) {
if (o == null) {
return null;
}
TimestampTZ t = (TimestampTZ) o;
TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo;
if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) {
t.setZonedDateTime(t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone()));
}
return new TimestampLocalTZWritable(t);
}
use of org.apache.hadoop.hive.common.type.TimestampTZ in project hive by apache.
the class JavaTimestampLocalTZObjectInspector method getPrimitiveJavaObject.
@Override
public TimestampTZ getPrimitiveJavaObject(Object o) {
if (o == null) {
return null;
}
TimestampTZ t = (TimestampTZ) o;
TimestampLocalTZTypeInfo timestampTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo;
if (!t.getZonedDateTime().getZone().equals(timestampTZTypeInfo.timeZone())) {
t.setZonedDateTime(t.getZonedDateTime().withZoneSameInstant(timestampTZTypeInfo.timeZone()));
}
return t;
}
use of org.apache.hadoop.hive.common.type.TimestampTZ in project hive by apache.
the class TestTimestampTZWritable method testSecondsWithNanos.
@Test
@Repeating(repetition = 10)
public void testSecondsWithNanos() {
long seconds = ThreadLocalRandom.current().nextLong(31556889864403199L);
if (ThreadLocalRandom.current().nextBoolean()) {
seconds = -seconds;
}
int nanos = ThreadLocalRandom.current().nextInt(999999999) + 1;
TimestampTZ tstz = new TimestampTZ(seconds, nanos, ZoneId.of("UTC"));
verifyConversion(tstz);
}
Aggregations