DateDatum extends Datum { @Override public int compareTo(Datum datum) { if (datum.type() == TajoDataTypes.Type.DATE) { DateDatum another = (DateDatum) datum; int compare = Ints.compare(year, another.year); if (compare != 0) { return compare; } compare = Ints.compare(monthOfYear, another.monthOfYear); if (compare != 0) { return compare; } return Ints.compare(dayOfMonth, another.dayOfMonth); } else if (datum.type() == TajoDataTypes.Type.TIMESTAMP) { TimestampDatum another = (TimestampDatum) datum; TimeMeta myMeta, otherMeta; myMeta = toTimeMeta(); otherMeta = another.toTimeMeta(); return myMeta.compareTo(otherMeta); } else if (datum instanceof NullDatum || datum.isNull()) { return -1; } else { throw new InvalidOperationException(datum.type()); } } DateDatum(int value);  DateDatum(TimeMeta tm); TimeMeta toTimeMeta(); int getCenturyOfEra(); int getYear(); int getWeekyear(); int getMonthOfYear(); int getDayOfYear(); int getDayOfWeek(); int getISODayOfWeek(); int getWeekOfYear(); int getDayOfMonth(); @Override String toString(); @Override Datum plus(Datum datum); @Override Datum minus(Datum datum); @Override int asInt4(); @Override long asInt8(); @Override float asFloat4(); @Override double asFloat8(); @Override String asChars(); @Override int size(); @Override byte [] asByteArray(); @Override Datum equalsTo(Datum datum); @Override int compareTo(Datum datum); @Override boolean equals(Object obj); @Override int hashCode(); static final int SIZE; }
@Test public void testCompareTo() { DateDatum theday = DatumFactory.createDate("2014-11-12"); DateDatum thedaybefore = DatumFactory.createDate("2014-11-11"); assertThat(theday.compareTo(thedaybefore) > 0, is(true)); assertThat(thedaybefore.compareTo(theday) > 0, is(false)); TimestampDatum timestamp = DatumFactory.createTimestamp("2014-11-12 15:00:00.68"); assertThat(timestamp.compareTo(theday) > 0, is(true)); }