@Override public String getString() { StringBuilder buff = new StringBuilder(DISPLAY_SIZE); appendDate(buff, dateValue); return buff.toString(); }
/** * Calculate the date value (in the default timezone) from a given time in * milliseconds in UTC. * * @param ms the milliseconds * @return the value */ public static ValueDate fromMillis(long ms) { return fromDateValue(DateTimeUtils.dateValueFromDate(ms)); }
/** * 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 updateDate(int columnIndex, Date x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateDate(" + columnIndex + ", x);"); } update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueDate.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
return ValueDate.fromDateValue( DateTimeUtils.dateValue(1970, 1, 1)); case TIMESTAMP: return ValueDate.fromDateValue( ((ValueTimestamp) this).getDateValue()); case DATE: return ValueTimestamp.fromDateValueAndNanos( ((ValueDate) this).getDateValue(), 0); return ValueTime.parse(s.trim()); case DATE: return ValueDate.parse(s.trim()); case TIMESTAMP: return ValueTimestamp.parse(s.trim());
@Override public Object getObject() { return getDate(); }
@Override public String getSQL() { return "DATE '" + getString() + "'"; }
/** * Convert the date to the specified time zone. * * @param value the date (might be ValueNull) * @param calendar the calendar * @return the date using the correct time zone */ public static Date convertDate(Value value, Calendar calendar) { if (value == ValueNull.INSTANCE) { return null; } ValueDate d = (ValueDate) value.convertTo(Value.DATE); Calendar cal = (Calendar) calendar.clone(); cal.clear(); cal.setLenient(true); long dateValue = d.getDateValue(); setCalendarFields(cal, yearFromDateValue(dateValue), monthFromDateValue(dateValue), dayFromDateValue(dateValue), 0, 0, 0, 0); long ms = cal.getTimeInMillis(); return new Date(ms); }
long now = session.getTransactionStart(); result = ValueDate.fromMillis(now); break;
String date = currentValue.getString(); read(); r = ValueExpression.get(ValueDate.parse(date)); } else if (equalsToken("TIME", name) || equalsToken("T", 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 updateDate(String columnLabel, Date x) throws SQLException { try { if (isDebugEnabled()) { debugCode("updateDate(" + quote(columnLabel) + ", x);"); } update(columnLabel, x == null ? (Value) ValueNull.INSTANCE : ValueDate.get(x)); } catch (Exception e) { throw logAndConvert(e); } }
@Override public void set(PreparedStatement prep, int parameterIndex) throws SQLException { prep.setDate(parameterIndex, getDate()); }
Date value = rs.getDate(columnIndex); v = value == null ? (Value) ValueNull.INSTANCE : ValueDate.get(value); break;
/** * Get or create a date value for the given date. * * @param date the date * @return the value */ public static ValueDate get(Date date) { return fromDateValue(DateTimeUtils.dateValueFromDate(date.getTime())); }
@Override public String getString() { StringBuilder buff = new StringBuilder(DISPLAY_SIZE); ValueDate.appendDate(buff, dateValue); buff.append(' '); ValueTime.appendTime(buff, timeNanos, true); return buff.toString(); }
/** * 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 setDate(int parameterIndex, java.sql.Date x) throws SQLException { try { if (isDebugEnabled()) { debugCode("setDate(" + parameterIndex + ", " + quoteDate(x) + ");"); } Value v = x == null ? (Value) ValueNull.INSTANCE : ValueDate.get(x); setParameter(parameterIndex, v); } catch (Exception e) { throw logAndConvert(e); } }
/** * Convert the date using the specified calendar. * * @param x the date * @param calendar the calendar * @return the date */ public static ValueDate convertDate(Date x, Calendar calendar) { if (calendar == null) { throw DbException.getInvalidValueException("calendar", null); } Calendar cal = (Calendar) calendar.clone(); cal.setTimeInMillis(x.getTime()); long dateValue = dateValueFromCalendar(cal); return ValueDate.fromDateValue(dateValue); }
return ValueBytes.get((byte[]) x); } else if (x instanceof Date) { return ValueDate.get((Date) x); } else if (x instanceof Time) { return ValueTime.get((Time) x);
/** * Parse a string to a ValueDate. * * @param s the string to parse * @return the date */ public static ValueDate parse(String s) { try { return fromDateValue(DateTimeUtils.parseDateValue(s, 0, s.length())); } catch (Exception e) { throw DbException.get(ErrorCode.INVALID_DATETIME_CONSTANT_2, e, "DATE", s); } }