@Override public String getString() { StringBuilder buff = new StringBuilder(DISPLAY_SIZE); appendTime(buff, nanos, false); return buff.toString(); }
/** * 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 updateTime(int columnIndex, Time x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateTime(" + columnIndex + ", x);"); } update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
return ValueTime.fromNanos(0); case TIMESTAMP: return ValueTime.fromNanos( ((ValueTimestamp) this).getTimeNanos()); case TIME: return DateTimeUtils.normalizeTimestamp( 0, ((ValueTime) this).getNanos()); case DATE: return ValueTimestamp.fromDateValueAndNanos( return ValueDecimal.get(new BigDecimal(s.trim())); case TIME: return ValueTime.parse(s.trim()); case DATE: return ValueDate.parse(s.trim());
@Override public Value negate() { return ValueTime.fromNanos(-nanos); }
@Override public Object getObject() { return getTime(); }
@Override public String getSQL() { return "TIME '" + getString() + "'"; }
/** * Convert the time to the specified time zone. * * @param value the time (might be ValueNull) * @param calendar the calendar * @return the time using the correct time zone */ public static Time convertTime(Value value, Calendar calendar) { if (value == ValueNull.INSTANCE) { return null; } ValueTime t = (ValueTime) value.convertTo(Value.TIME); Calendar cal = (Calendar) calendar.clone(); cal.clear(); cal.setLenient(true); long nanos = t.getNanos(); long millis = nanos / 1000000; nanos -= millis * 1000000; long s = millis / 1000; millis -= s * 1000; long m = s / 60; s -= m * 60; long h = m / 60; m -= h * 60; setCalendarFields(cal, 1970, 1, 1, (int) h, (int) m, (int) s, (int) millis); long ms = cal.getTimeInMillis(); return new Time(ms); }
long now = session.getTransactionStart(); result = ValueTime.fromMillis(now); break;
String time = currentValue.getString(); read(); r = ValueExpression.get(ValueTime.parse(time)); } else if (equalsToken("TIMESTAMP", name) || equalsToken("TS", name)) {
/** * 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 updateTime(String columnLabel, Time x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateTime(" + quote(columnLabel) + ", x);"); } update(columnLabel, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
/** * Get or create a time value for the given time. * * @param time the time * @return the value */ public static ValueTime get(Time time) { return fromNanos(DateTimeUtils.nanosFromDate(time.getTime())); }
@Override public void set(PreparedStatement prep, int parameterIndex) throws SQLException { prep.setTime(parameterIndex, getTime()); }
/** * 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 setTime(int parameterIndex, java.sql.Time x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setTime(" + parameterIndex + ", " + quoteTime(x) + ");"); } Value v = x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x); setParameter(parameterIndex, v); } catch (Exception e) { throw logAndConvert(e); } }
/** * Calculate the time value from a given time in * milliseconds in UTC. * * @param ms the milliseconds * @return the value */ public static ValueTime fromMillis(long ms) { return fromNanos(DateTimeUtils.nanosFromDate(ms)); }
@Override public String getString() { StringBuilder buff = new StringBuilder(DISPLAY_SIZE); ValueDate.appendDate(buff, dateValue); buff.append(' '); ValueTime.appendTime(buff, timeNanos, true); return buff.toString(); }
Time value = rs.getTime(columnIndex); v = value == null ? (Value) ValueNull.INSTANCE : ValueTime.get(value); break;
@Override public Value divide(Value v) { return ValueTime.fromNanos((long) (nanos / v.getDouble())); }