public long set(long instant, String text, Locale locale) { // cannot verify that new value stuck because set may be lenient long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.set(localInstant, text, locale); return iZone.convertLocalToUTC(localInstant, false, instant); }
public long set(long instant, String text, Locale locale) { // cannot verify that new value stuck because set may be lenient long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.set(localInstant, text, locale); return iZone.convertLocalToUTC(localInstant, false, instant); }
private static long getLongExpressedValue(Object value, DateTimeZone hiveTimeZone) { if (value instanceof Date) { long storageTime = ((Date) value).getTime(); // convert date from VM current time zone to UTC long utcMillis = storageTime + DateTimeZone.getDefault().getOffset(storageTime); return TimeUnit.MILLISECONDS.toDays(utcMillis); } if (value instanceof Timestamp) { // The Hive SerDe parses timestamps using the default time zone of // this JVM, but the data might have been written using a different // time zone. We need to convert it to the configured time zone. // the timestamp that Hive parsed using the JVM time zone long parsedJvmMillis = ((Timestamp) value).getTime(); // remove the JVM time zone correction from the timestamp DateTimeZone jvmTimeZone = DateTimeZone.getDefault(); long hiveMillis = jvmTimeZone.convertUTCToLocal(parsedJvmMillis); // convert to UTC using the real time zone for the underlying data long utcMillis = hiveTimeZone.convertLocalToUTC(hiveMillis, false); return utcMillis; } if (value instanceof Float) { return floatToRawIntBits(((Float) value)); } return ((Number) value).longValue(); }
public long add(long instant, long value) { if (iTimeField) { int offset = getOffsetToAdd(instant); long localInstant = iField.add(instant + offset, value); return localInstant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.add(localInstant, value); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long roundCeiling(long instant) { if (iTimeField) { int offset = getOffsetToAdd(instant); instant = iField.roundCeiling(instant + offset); return instant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.roundCeiling(localInstant); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long addWrapField(long instant, int value) { if (iTimeField) { int offset = getOffsetToAdd(instant); long localInstant = iField.addWrapField(instant + offset, value); return localInstant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.addWrapField(localInstant, value); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long roundFloor(long instant) { if (iTimeField) { int offset = getOffsetToAdd(instant); instant = iField.roundFloor(instant + offset); return instant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.roundFloor(localInstant); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long roundFloor(long instant) { if (iTimeField) { int offset = getOffsetToAdd(instant); instant = iField.roundFloor(instant + offset); return instant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.roundFloor(localInstant); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long roundCeiling(long instant) { if (iTimeField) { int offset = getOffsetToAdd(instant); instant = iField.roundCeiling(instant + offset); return instant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.roundCeiling(localInstant); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long add(long instant, int value) { if (iTimeField) { int offset = getOffsetToAdd(instant); long localInstant = iField.add(instant + offset, value); return localInstant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.add(localInstant, value); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long addWrapField(long instant, int value) { if (iTimeField) { int offset = getOffsetToAdd(instant); long localInstant = iField.addWrapField(instant + offset, value); return localInstant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.addWrapField(localInstant, value); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long add(long instant, int value) { if (iTimeField) { int offset = getOffsetToAdd(instant); long localInstant = iField.add(instant + offset, value); return localInstant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.add(localInstant, value); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long add(long instant, long value) { if (iTimeField) { int offset = getOffsetToAdd(instant); long localInstant = iField.add(instant + offset, value); return localInstant - offset; } else { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.add(localInstant, value); return iZone.convertLocalToUTC(localInstant, false, instant); } }
public long set(long instant, int value) { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.set(localInstant, value); long result = iZone.convertLocalToUTC(localInstant, false, instant); if (get(result) != value) { IllegalInstantException cause = new IllegalInstantException(localInstant, iZone.getID()); IllegalFieldValueException ex = new IllegalFieldValueException(iField.getType(), Integer.valueOf(value), cause.getMessage()); ex.initCause(cause); throw ex; } return result; }
public long set(long instant, int value) { long localInstant = iZone.convertUTCToLocal(instant); localInstant = iField.set(localInstant, value); long result = iZone.convertLocalToUTC(localInstant, false, instant); if (get(result) != value) { IllegalInstantException cause = new IllegalInstantException(localInstant, iZone.getID()); IllegalFieldValueException ex = new IllegalFieldValueException(iField.getType(), Integer.valueOf(value), cause.getMessage()); ex.initCause(cause); throw ex; } return result; }
/** * Set values which may be out of bounds by adding the difference between * the new value and the current value. */ public long set(long instant, int value) { // lenient needs to handle time zone chronologies // so we do the calculation using local milliseconds long localInstant = iBase.getZone().convertUTCToLocal(instant); long difference = FieldUtils.safeSubtract(value, get(instant)); localInstant = getType().getField(iBase.withUTC()).add(localInstant, difference); return iBase.getZone().convertLocalToUTC(localInstant, false, instant); } }
/** * Set values which may be out of bounds by adding the difference between * the new value and the current value. */ public long set(long instant, int value) { // lenient needs to handle time zone chronologies // so we do the calculation using local milliseconds long localInstant = iBase.getZone().convertUTCToLocal(instant); long difference = FieldUtils.safeSubtract(value, get(instant)); localInstant = getType().getField(iBase.withUTC()).add(localInstant, difference); return iBase.getZone().convertLocalToUTC(localInstant, false, instant); } }
@ScalarOperator(CAST) @SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) public static long castToTimestampWithTimeZone(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value) { if (session.isLegacyTimestamp()) { return packDateTimeWithZone(value, session.getTimeZoneKey()); } else { ISOChronology localChronology = getChronology(session.getTimeZoneKey()); // This cast does treat TIMESTAMP as wall time in session TZ. This means that in order to get // its UTC representation we need to shift the value by the offset of TZ. return packDateTimeWithZone(localChronology.getZone().convertLocalToUTC(value, false), session.getTimeZoneKey()); } }
@ScalarOperator(CAST) @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long castToTimeWithTimeZone(ConnectorSession session, @SqlType(StandardTypes.TIME) long value) { if (session.isLegacyTimestamp()) { return packDateTimeWithZone(value, session.getTimeZoneKey()); } else { ISOChronology localChronology = getChronology(session.getTimeZoneKey()); // This cast does treat TIME as wall time in session TZ. This means that in order to get // its UTC representation we need to shift the value by the offset of TZ. // We use value offset in this place to be sure that we will have same hour represented // in TIME WITH TIME ZONE. Calculating real TZ offset will happen when really required. // This is done due to inadequate TIME WITH TIME ZONE representation. return packDateTimeWithZone(localChronology.getZone().convertLocalToUTC(value, false), session.getTimeZoneKey()); } }
@ScalarOperator(CAST) @SqlType(StandardTypes.TIME_WITH_TIME_ZONE) public static long castToTimeWithTimeZone(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long value) { if (session.isLegacyTimestamp()) { int timeMillis = modulo24Hour(getChronology(session.getTimeZoneKey()), value); return packDateTimeWithZone(timeMillis, session.getTimeZoneKey()); } else { ISOChronology localChronology = getChronology(session.getTimeZoneKey()); // This cast does treat TIMESTAMP as wall time in session TZ. This means that in order to get // its UTC representation we need to shift the value by the offset of TZ. return packDateTimeWithZone(localChronology.getZone().convertLocalToUTC(modulo24Hour(value), false), session.getTimeZoneKey()); } }