TimestampDatum extends Datum { public String asChars(TimeZone timeZone, boolean includeTimeZone) { TimeMeta tm = toTimeMeta(); DateTimeUtil.toUserTimezone(tm, timeZone); if (includeTimeZone) { tm.timeZone = timeZone.getRawOffset() / 1000; } return DateTimeUtil.encodeDateTime(tm, DateStyle.ISO_DATES); } TimestampDatum(long timestamp); long getTimestamp(); int getEpoch(); long getJavaTimestamp(); int getCenturyOfEra(); int getYear(); int getMonthOfYear(); int getDayOfYear(); int getDayOfWeek(); int getWeekOfYear(); int getDayOfMonth(); int getHourOfDay(); int getMinuteOfHour(); int getSecondOfMinute(); int getMillisOfSecond(); int getUnixTime(); String toString(); String asChars(TimeZone timeZone, boolean includeTimeZone); String toString(TimeZone timeZone, boolean includeTimeZone); @Override long asInt8(); @Override String asChars(); String toChars(String format); @Override int size(); @Override byte [] asByteArray(); @Override Datum equalsTo(Datum datum); @Override int compareTo(Datum datum); @Override boolean equals(Object obj); @Override Datum plus(Datum datum); @Override Datum minus(Datum datum); @Override int hashCode(); TimeMeta toTimeMeta(); static final int SIZE; }
@Test public final void testAsText() { Datum d = DatumFactory.createTimestamp("1980-04-01 01:50:01"); Datum copy = DatumFactory.createTimestamp(d.asChars()); assertEquals(d, copy); d = DatumFactory.createTimestamp("1980-04-01 01:50:01.10"); copy = DatumFactory.createTimestamp(d.asChars()); assertEquals(d, copy); }
@Test public void testAsText2() { TimestampDatum datum = DatumFactory.createTimestamp("Mon Nov 03 00:03:00 +0000 2014"); assertEquals("2014-11-03 00:03:00", datum.asChars()); }
@Test public final void testTimeZone() { TimestampDatum datum = new TimestampDatum(DateTimeUtil.toJulianTimestamp(2014, 5, 1, 15, 20, 30, 0)); assertEquals("2014-05-01 15:20:30", datum.asChars()); assertEquals("2014-05-02 00:20:30+09", datum.asChars(TimeZone.getTimeZone("GMT+9"), true)); }