/** * Get or create a date value for the given date. * * @param dateValue the date value, a bit field with bits for the year, * month, and day * @param timeNanos the nanoseconds since midnight * @return the value */ public static ValueTimestamp fromDateValueAndNanos(long dateValue, long timeNanos) { return (ValueTimestamp) cache(new ValueTimestamp(dateValue, timeNanos)); }
/** * Calculate the normalized timestamp. * * @param absoluteDay the absolute day * @param nanos the nanoseconds (may be negative or larger than one day) * @return the timestamp */ public static ValueTimestamp normalizeTimestamp(long absoluteDay, long nanos) { if (nanos > NANOS_PER_DAY || nanos < 0) { long d; if (nanos > NANOS_PER_DAY) { d = nanos / NANOS_PER_DAY; } else { d = (nanos - NANOS_PER_DAY + 1) / NANOS_PER_DAY; } nanos -= d * NANOS_PER_DAY; absoluteDay += d; } return ValueTimestamp.fromDateValueAndNanos( dateValueFromAbsoluteDay(absoluteDay), nanos); }
@Override public String getSQL() { return "TIMESTAMP '" + getString() + "'"; }
return ValueTime.get((Time) x); } else if (x instanceof Timestamp) { return ValueTimestamp.get((Timestamp) x); } else if (x instanceof java.util.Date) { return ValueTimestamp.fromMillis(((java.util.Date) x).getTime()); } else if (x instanceof java.io.Reader) { Reader r = new BufferedReader((java.io.Reader) x);
case TIMESTAMP: return ValueDate.fromDateValue( ((ValueTimestamp) this).getDateValue()); case TIMESTAMP: return ValueTime.fromNanos( ((ValueTimestamp) this).getTimeNanos()); 0, ((ValueTime) this).getNanos()); case DATE: return ValueTimestamp.fromDateValueAndNanos( ((ValueDate) this).getDateValue(), 0); return ValueDate.parse(s.trim()); case TIMESTAMP: return ValueTimestamp.parse(s.trim()); case BYTES: return ValueBytes.getNoCopy(
/** * Updates a column in the current or insert row. * * @param columnIndex (1,2,...) * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateTimestamp(" + columnIndex + ", x);"); } update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueTimestamp.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
@Override public Object getObject() { return getTimestamp(); }
cal.clear(); cal.setLenient(true); long dateValue = ts.getDateValue(); long nanos = ts.getTimeNanos(); long millis = nanos / 1000000; nanos -= millis * 1000000;
case CURRENT_TIMESTAMP: { long now = session.getTransactionStart(); ValueTimestamp vt = ValueTimestamp.fromMillis(now); if (v0 != null) { Mode mode = database.getMode(); vt = (ValueTimestamp) vt.convertScale( mode.convertOnlyToSmallerScale, v0.getInt());
c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); result = ValueTimestamp.fromMillis(c.getTimeInMillis()); } else { double d = v0.getDouble(); break; case DATE_ADD: result = ValueTimestamp.get(dateadd( v0.getString(), v1.getInt(), v2.getTimestamp())); break; java.util.Date d = DateTimeUtils.parseDateTime( v0.getString(), v1.getString(), locale, tz); result = ValueTimestamp.fromMillis(d.getTime());
/** * Updates a column in the current or insert row. * * @param columnLabel the column label * @param x the value * @throws SQLException if the result set is closed or not updatable */ @Override public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateTimestamp(" + quote(columnLabel) + ", x);"); } update(columnLabel, x == null ? (Value) ValueNull.INSTANCE : ValueTimestamp.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
@Override public void set(PreparedStatement prep, int parameterIndex) throws SQLException { prep.setTimestamp(parameterIndex, getTimestamp()); }
/** * Sets the value of a parameter. * * @param parameterIndex the parameter index (1, 2, ...) * @param x the value * @throws SQLException if this object is closed */ @Override public void setTimestamp(int parameterIndex, java.sql.Timestamp x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setTimestamp(" + parameterIndex + ", " + quoteTimestamp(x) + ");"); } Value v = x == null ? (Value) ValueNull.INSTANCE : ValueTimestamp.get(x); setParameter(parameterIndex, v); } catch (Exception e) { throw logAndConvert(e); } }
/** * Get or create a timestamp value for the given timestamp. * * @param timestamp the timestamp * @return the value */ public static ValueTimestamp get(Timestamp timestamp) { long ms = timestamp.getTime(); long nanos = timestamp.getNanos() % 1000000; long dateValue = DateTimeUtils.dateValueFromDate(ms); nanos += DateTimeUtils.nanosFromDate(ms); return fromDateValueAndNanos(dateValue, nanos); }
private long getTime(Value value) { int type; type = value.getType(); switch (type) { case Value.DATE: case Value.TIME: case Value.TIMESTAMP: ValueTimestamp v = (ValueTimestamp) value.convertTo(Value.TIMESTAMP); return v.getTimestamp().getTime(); default: throw new RuleEvaluateException("Invalid type for " + getClass().getName()); } } }
Timestamp value = rs.getTimestamp(columnIndex); v = value == null ? (Value) ValueNull.INSTANCE : ValueTimestamp.get(value); break;
/** * Get or create a timestamp value for the given date/time in millis. * * @param ms the milliseconds * @return the value */ public static ValueTimestamp fromMillis(long ms) { long dateValue = DateTimeUtils.dateValueFromDate(ms); long nanos = DateTimeUtils.nanosFromDate(ms); return fromDateValueAndNanos(dateValue, nanos); }
case Value.TIMESTAMP: ValueTimestamp v = (ValueTimestamp) value.convertTo(Value.TIMESTAMP); long toLong = v.getTimestamp().getTime(); return partitionUtil.partition(toLong); case Value.STRING:
/** * Get or create a timestamp value for the given date/time in millis. * * @param ms the milliseconds * @param nanos the nanoseconds * @return the value */ public static ValueTimestamp fromMillisNanos(long ms, int nanos) { long dateValue = DateTimeUtils.dateValueFromDate(ms); long timeNanos = nanos + DateTimeUtils.nanosFromDate(ms); return fromDateValueAndNanos(dateValue, timeNanos); }
case Value.TIMESTAMP: ValueTimestamp v = (ValueTimestamp) value.convertTo(Value.TIMESTAMP); long toLong = v.getTimestamp().getTime(); bytes = ValueLong.get(toLong).getBytes(); break;