/** * 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 Value readValue(ByteBuffer buff) { return ValueDate.fromDateValue(DataUtils.readVarLong(buff)); }
/** * 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); }
/** * 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); } }
return ValueDate.fromDateValue(DateTimeUtils.dateValue(1970, 1, 1)); case TIMESTAMP: return ValueDate.fromDateValue(((ValueTimestamp) this).getDateValue());
return ValueByte.get(readByte()); case Value.DATE: return ValueDate.fromDateValue(readLong()); case Value.TIME: return ValueTime.fromNanos(readLong());