class ValueDate extends Value {

    /**
     * The precision in digits.
     */
    public static final int PRECISION = 8;

    /**
     * The display size of the textual representation of a date.
     * Example: 2000-01-02
     */
    public static final int DISPLAY_SIZE = 10;

    private final long dateValue;

    private ValueDate(long dateValue) {
        this.dateValue = dateValue;
    }

    /**
     * Get or create a date value for the given date.
     *
     * @param dateValue the date value
     * @return the value
     */
    public static ValueDate fromDateValue(long dateValue) {
        return (ValueDate) Value.cache(new ValueDate(dateValue));
    }

    /**
     * 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()));
    }

    /**
     * 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);
        }
    }

    public long getDateValue() {
        return dateValue;
    }

    @Override
    public Date getDate() {
        return DateTimeUtils.convertDateValueToDate(dateValue);
    }

    @Override
    public int getType() {
        return Value.DATE;
    }

    @Override
    public String getString() {
        StringBuilder buff = new StringBuilder(DISPLAY_SIZE);
        appendDate(buff, dateValue);
        return buff.toString();
    }

    @Override
    public String getSQL() {
        return "DATE '" + getString() + "'";
    }

    @Override
    public long getPrecision() {
        return PRECISION;
    }

    @Override
    public int getDisplaySize() {
        return DISPLAY_SIZE;
    }

    @Override
    protected int compareSecure(Value o, CompareMode mode) {
        return MathUtils.compareLong(dateValue, ((ValueDate) o).dateValue);
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }
        return other instanceof ValueDate && dateValue == (((ValueDate) other).dateValue);
    }

    @Override
    public int hashCode() {
        return (int) (dateValue ^ (dateValue >>> 32));
    }

    @Override
    public Object getObject() {
        return getDate();
    }

    @Override
    public void set(PreparedStatement prep, int parameterIndex) throws SQLException {
        prep.setDate(parameterIndex, getDate());
    }

    /**
     * Append a date to the string builder.
     *
     * @param buff the target string builder
     * @param dateValue the date value
     */
    static void appendDate(StringBuilder buff, long dateValue) {<FILL_FUNCTION_BODY>}

    public static final StorageDataTypeBase type = new StorageDataTypeBase() {

        @Override
        public int getType() {
            return DATE;
        }

        @Override
        public int compare(Object aObj, Object bObj) {
            Date a = (Date) aObj;
            Date b = (Date) bObj;
            return a.compareTo(b);
        }

        @Override
        public int getMemory(Object obj) {
            return 24;
        }

        @Override
        public void write(DataBuffer buff, Object obj) {
            Date d = (Date) obj;
            write0(buff, d.getTime());
        }

        @Override
        public void writeValue(DataBuffer buff, Value v) {
            long d = ((ValueDate) v).getDateValue();
            write0(buff, d);
        }

        private void write0(DataBuffer buff, long v) {
            buff.put((byte) Value.DATE).putVarLong(v);
        }

        @Override
        public Value readValue(ByteBuffer buff) {
            return ValueDate.fromDateValue(DataUtils.readVarLong(buff));
        }
    };
}

        int y = DateTimeUtils.yearFromDateValue(dateValue);
        int m = DateTimeUtils.monthFromDateValue(dateValue);
        int d = DateTimeUtils.dayFromDateValue(dateValue);
        if (y > 0 && y < 10000) {
            StringUtils.appendZeroPadded(buff, 4, y);
        } else {
            buff.append(y);
        }
        buff.append('-');
        StringUtils.appendZeroPadded(buff, 2, m);
        buff.append('-');
        StringUtils.appendZeroPadded(buff, 2, d);
    
<methods>public non-sealed void <init>() ,public com.lealone.db.value.Value add(com.lealone.db.value.Value) ,public boolean checkPrecision(long) ,public static void clearCache() ,public void close() ,public int compareTo(com.lealone.db.value.Value) ,public final int compareTo(com.lealone.db.value.Value, com.lealone.db.value.CompareMode) ,public final int compareTypeSafe(com.lealone.db.value.Value, com.lealone.db.value.CompareMode) ,public com.lealone.db.value.Value convertPrecision(long, boolean) ,public com.lealone.db.value.Value convertScale(boolean, int) ,public com.lealone.db.value.Value convertTo(int) ,public com.lealone.db.value.Value divide(com.lealone.db.value.Value) ,public abstract boolean equals(java.lang.Object) ,public java.sql.Array getArray() ,public java.math.BigDecimal getBigDecimal() ,public java.sql.Blob getBlob() ,public boolean getBoolean() ,public byte getByte() ,public byte[] getBytes() ,public byte[] getBytesNoCopy() ,public java.sql.Clob getClob() ,public T getCollection() ,public java.sql.Date getDate() ,public abstract int getDisplaySize() ,public double getDouble() ,public float getFloat() ,public static int getHigherOrder(int, int) ,public java.io.InputStream getInputStream() ,public int getInt() ,public long getLong() ,public int getMemory() ,public abstract java.lang.Object getObject() ,public abstract long getPrecision() ,public java.io.Reader getReader() ,public java.sql.ResultSet getResultSet() ,public abstract java.lang.String getSQL() ,public int getScale() ,public short getShort() ,public int getSignum() ,public abstract java.lang.String getString() ,public java.sql.Time getTime() ,public java.sql.Timestamp getTimestamp() ,public java.lang.String getTraceSQL() ,public abstract int getType() ,public java.util.UUID getUuid() ,public abstract int hashCode() ,public final boolean isFalse() ,public com.lealone.db.value.Value modulus(com.lealone.db.value.Value) ,public com.lealone.db.value.Value multiply(com.lealone.db.value.Value) ,public com.lealone.db.value.Value negate() ,public abstract void set(java.sql.PreparedStatement, int) throws java.sql.SQLException,public com.lealone.db.value.Value subtract(com.lealone.db.value.Value) ,public java.lang.String toString() <variables>public static final int ARRAY,public static final int BLOB,public static final int BOOLEAN,public static final int BYTE,public static final int BYTES,public static final int CLOB,private static final com.lealone.db.value.CompareMode COMPARE_MODE,public static final int DATE,public static final int DECIMAL,public static final int DOUBLE,public static final int ENUM,public static final int FLOAT,public static final int INT,public static final int JAVA_OBJECT,public static final int LIST,public static final int LONG,public static final int MAP,private static final java.math.BigDecimal MAX_LONG_DECIMAL,private static final java.math.BigDecimal MIN_LONG_DECIMAL,public static final int NULL,public static final int RESULT_SET,public static final int SET,public static final int SHORT,public static final int STRING,public static final int STRING_FIXED,public static final int STRING_IGNORECASE,public static final int TIME,public static final int TIMESTAMP,public static final int TYPE_COUNT,public static final int UNKNOWN,public static final int UUID,private static SoftReference<com.lealone.db.value.Value[]> softCache