@Override public Object toObject(String value) { return PDate.INSTANCE.toObject(value); }
@Override public Object toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { Date d = (Date) PDate.INSTANCE.toObject(b, o, l, actualType, sortOrder); throwIfNonNegativeDate(d); return d; }
@Override public Object toObject(Object object, PDataType actualType) { Date d = (Date) PDate.INSTANCE.toObject(object, actualType); throwIfNonNegativeDate(d); return d; }
@Test public void testDateConversions() { long now = System.currentTimeMillis(); Date date = new Date(now); Time t = new Time(now); Timestamp ts = new Timestamp(now); Object o = PDate.INSTANCE.toObject(ts, PTimestamp.INSTANCE); assertEquals(o.getClass(), java.sql.Date.class); o = PDate.INSTANCE.toObject(t, PTime.INSTANCE); assertEquals(o.getClass(), java.sql.Date.class); o = PTime.INSTANCE.toObject(date, PDate.INSTANCE); assertEquals(o.getClass(), java.sql.Time.class); o = PTime.INSTANCE.toObject(ts, PTimestamp.INSTANCE); assertEquals(o.getClass(), java.sql.Time.class); o = PTimestamp.INSTANCE.toObject(date, PDate.INSTANCE); assertEquals(o.getClass(), java.sql.Timestamp.class); o = PTimestamp.INSTANCE.toObject(t, PTime.INSTANCE); assertEquals(o.getClass(), java.sql.Timestamp.class); }
@Override public Object toObject(String value) { return PDate.INSTANCE.toObject(value); }
@Override public Object toObject(String value) { return PDate.INSTANCE.toObject(value); }
private static void assertRow2(Iterator<Cell> iterator, byte[] expectedRowKey2) { Cell kv; kv = iterator.next(); assertArrayEquals(expectedRowKey2, CellUtil.cloneRow(kv)); assertEquals(QueryConstants.EMPTY_COLUMN_VALUE, PVarchar.INSTANCE.toObject(CellUtil.cloneValue(kv))); assertTrue(iterator.hasNext()); kv = iterator.next(); assertArrayEquals(expectedRowKey2, CellUtil.cloneRow(kv)); assertEquals(name2, PVarchar.INSTANCE.toObject(CellUtil.cloneValue(kv))); assertTrue(iterator.hasNext()); kv = iterator.next(); assertArrayEquals(expectedRowKey2, CellUtil.cloneRow(kv)); assertEquals(now, PDate.INSTANCE.toObject(CellUtil.cloneValue(kv))); }
private static void assertRow1(Iterator<Cell> iterator, byte[] expectedRowKey1) { Cell kv; assertTrue(iterator.hasNext()); kv = iterator.next(); assertArrayEquals(expectedRowKey1, CellUtil.cloneRow(kv)); assertEquals(QueryConstants.EMPTY_COLUMN_VALUE, PVarchar.INSTANCE.toObject(CellUtil.cloneValue(kv))); kv = iterator.next(); assertArrayEquals(expectedRowKey1, CellUtil.cloneRow(kv)); assertEquals(name1, PVarchar.INSTANCE.toObject(CellUtil.cloneValue(kv))); assertTrue(iterator.hasNext()); kv = iterator.next(); assertArrayEquals(expectedRowKey1, CellUtil.cloneRow(kv)); assertEquals(now, PDate.INSTANCE.toObject(CellUtil.cloneValue(kv))); }
@Override public Object toObject(Object object, PDataType actualType) { Date d = (Date) PDate.INSTANCE.toObject(object, actualType); throwIfNonNegativeDate(d); return d; }
@Override public Object toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { Date d = (Date) PDate.INSTANCE.toObject(b, o, l, actualType, sortOrder); throwIfNonNegativeDate(d); return d; }
@Override public Object toObject(byte[] b, int o, int l, PDataType actualType, SortOrder sortOrder, Integer maxLength, Integer scale) { Date d = (Date) PDate.INSTANCE.toObject(b, o, l, actualType, sortOrder); throwIfNonNegativeDate(d); return d; }
@Override public Object toObject(Object object, PDataType actualType) { Date d = (Date) PDate.INSTANCE.toObject(object, actualType); throwIfNonNegativeDate(d); return d; }