@Test public void testToTimestamp_slash() throws Exception { TimestampType timestampType = new TimestampType(); assertEquals(Timestamp.valueOf("2008-01-01 01:02:03"), timestampType.toTimestamp("2008/01/01 01:02:03")); assertEquals(Timestamp.valueOf("2008-01-01 01:02:03"), timestampType.toTimestamp("2008/01/01 01:02:03")); }
protected Timestamp toTimestamp(String value) { String pattern = null; if (value.contains("-")) { pattern = "yyyy-MM-dd HH:mm:ss"; } else { pattern = "yyyy/MM/dd HH:mm:ss"; } Timestamp timestamp = TimestampConversionUtil.toTimestamp(value, pattern); int pos = value.indexOf('.'); if (pos > -1) { int nanos = IntegerConversionUtil.toPrimitiveInt(value .substring(pos + 1)); if (nanos > 0) { int n = (int) Math.log10(nanos); if (n < 8) { nanos *= (int) Math.pow(10, 8 - n); } } timestamp.setNanos(nanos); } return timestamp; }
TimestampType extends AbstractSqlType { protected Timestamp toTimestamp(String value) { String pattern = null; if (value.contains("-")) { pattern = "yyyy-MM-dd HH:mm:ss"; } else { pattern = "yyyy/MM/dd HH:mm:ss"; } Timestamp timestamp = TimestampConversionUtil.toTimestamp(value, pattern); int pos = value.indexOf('.'); if (pos > -1) { int nanos = IntegerConversionUtil.toPrimitiveInt(value .substring(pos + 1)); if (nanos > 0) { int n = (int) Math.log10(nanos); if (n < 8) { nanos *= (int) Math.pow(10, 8 - n); } } timestamp.setNanos(nanos); } return timestamp; } }
TimestampType extends AbstractSqlType { protected Timestamp toTimestamp(String value) { String pattern = null; if (value.contains("-")) { pattern = "yyyy-MM-dd HH:mm:ss"; } else { pattern = "yyyy/MM/dd HH:mm:ss"; } Timestamp timestamp = TimestampConversionUtil.toTimestamp(value, pattern); int pos = value.indexOf('.'); if (pos > -1) { int nanos = IntegerConversionUtil.toPrimitiveInt(value .substring(pos + 1)); if (nanos > 0) { int n = (int) Math.log10(nanos); if (n < 8) { nanos *= (int) Math.pow(10, 8 - n); } } timestamp.setNanos(nanos); } return timestamp; } TimestampType();  TimestampType(String dataType); }
TimestampType extends AbstractSqlType { protected Timestamp toTimestamp(String value) { String pattern = null; if (value.contains("-")) { pattern = "yyyy-MM-dd HH:mm:ss"; } else { pattern = "yyyy/MM/dd HH:mm:ss"; } Timestamp timestamp = TimestampConversionUtil.toTimestamp(value, pattern); int pos = value.indexOf('.'); if (pos > -1) { int nanos = IntegerConversionUtil.toPrimitiveInt(value .substring(pos + 1)); if (nanos > 0) { int n = (int) Math.log10(nanos); if (n < 8) { nanos *= (int) Math.pow(10, 8 - n); } } timestamp.setNanos(nanos); } return timestamp; } TimestampType();  TimestampType(String dataType); void bindValue(PreparedStatement ps, int index, String value); String getValue(ResultSet resultSet, int index); }
TimestampType extends AbstractSqlType { protected Timestamp toTimestamp(String value) { String pattern = null; if (value.contains("-")) { pattern = "yyyy-MM-dd HH:mm:ss"; } else { pattern = "yyyy/MM/dd HH:mm:ss"; } Timestamp timestamp = TimestampConversionUtil.toTimestamp(value, pattern); int pos = value.indexOf('.'); if (pos > -1) { int nanos = IntegerConversionUtil.toPrimitiveInt(value .substring(pos + 1)); if (nanos > 0) { int n = (int) Math.log10(nanos); if (n < 8) { nanos *= (int) Math.pow(10, 8 - n); } } timestamp.setNanos(nanos); } return timestamp; } TimestampType();  TimestampType(String dataType); void bindValue(PreparedStatement ps, int index, String value); String getValue(ResultSet resultSet, int index);  }