DateUtil { public static Timestamp parseTimestamp(String timestampValue) { return new Timestamp(parseDateTime(timestampValue)); } private  DateUtil(); static DateTimeParser getDateTimeParser(String pattern, PDataType pDataType, String timeZoneId); static DateTimeParser getDateTimeParser(String pattern, PDataType pDataType); static Format getDateFormatter(String pattern); static Format getTimeFormatter(String pattern); static Format getTimestampFormatter(String pattern); static Date parseDate(String dateValue); static Time parseTime(String timeValue); static Timestamp parseTimestamp(String timestampValue); static Timestamp getTimestamp(long millis, int nanos); static Timestamp getTimestamp(BigDecimal bd); static final String DEFAULT_TIME_ZONE_ID; static final String LOCAL_TIME_ZONE_ID; static final String DEFAULT_MS_DATE_FORMAT; static final Format DEFAULT_MS_DATE_FORMATTER; static final String DEFAULT_DATE_FORMAT; static final Format DEFAULT_DATE_FORMATTER; static final String DEFAULT_TIME_FORMAT; static final Format DEFAULT_TIME_FORMATTER; static final String DEFAULT_TIMESTAMP_FORMAT; static final Format DEFAULT_TIMESTAMP_FORMATTER; }
@Test public void testParseTimestamp() { assertEquals(10000L, DateUtil.parseTimestamp("1970-01-01 00:00:10").getTime()); }
@Test public void testParseTimestamp_WithMillis() { assertEquals(10123L, DateUtil.parseTimestamp("1970-01-01 00:00:10.123").getTime()); }
@Test(expected=IllegalDataException.class) public void testParseTimestamp_InvalidTimestamp() { DateUtil.parseTimestamp("not-a-timestamp"); }