@Override public Date convert(Object val) throws ConverterException { if (val instanceof TIMESTAMP) { try { return ((TIMESTAMP)val).timestampValue(); } catch (SQLException e) { throw new ConverterException("Error trying to convert oracle.sql.TIMESTAMP to DateTime", e); } } return super.convert(val); }
return ((oracle.sql.TIMESTAMP) value).toJdbc().toString(); } catch (SQLException e) {
/** * Converts {@link LocalDateTime} to {@link TIMESTAMP}. * * @param attribute the value to be converted, possibly {@code null} * @return the converted data, possibly {@code null} */ public static TIMESTAMP localDateTimeToTimestamp(LocalDateTime attribute) { if (attribute == null) { return null; } byte[] bytes = newTimestampBuffer(); writeDateTime(bytes, attribute); return new TIMESTAMP(bytes); }
/** * Converts {@link TIMESTAMP} to {@link LocalDateTime}. * * @param dbData the data from the database to be converted, possibly {@code null} * @return the converted value, possibly {@code null} */ public static LocalDateTime timestampToLocalDateTime(TIMESTAMP dbData) { if (dbData == null) { return null; } byte[] bytes = dbData.toBytes(); return extractLocalDateTime(bytes); }
/** * Converts {@link TIMESTAMP} to {@link LocalDateTime}. * * @param dbData the data from the database to be converted, possibly {@code null} * @return the converted value, possibly {@code null} */ public static LocalDateTime timestampToLocalDateTime(TIMESTAMP dbData) { if (dbData == null) { return null; } byte[] bytes = dbData.toBytes(); return extractLocalDateTime(bytes); }
@Override public Date convert(Object val) throws ConverterException { if (val instanceof TIMESTAMP) { try { return ((TIMESTAMP)val).timestampValue(); } catch (SQLException e) { throw new ConverterException("Error trying to convert oracle.sql.TIMESTAMP to DateTime", e); } } return super.convert(val); }
}else{ if (colObj instanceof oracle.sql.Datum){ colObj = ((oracle.sql.TIMESTAMP)colObj).toJdbc();
/** * Converts {@link LocalDateTime} to {@link TIMESTAMP}. * * @param attribute the value to be converted, possibly {@code null} * @return the converted data, possibly {@code null} */ public static TIMESTAMP localDateTimeToTimestamp(LocalDateTime attribute) { if (attribute == null) { return null; } byte[] bytes = newTimestampBuffer(); writeDateTime(bytes, attribute); return new TIMESTAMP(bytes); }
@Test public void shouldReturnContentsOfClobIFAllOkay() throws SQLException { TIMESTAMP ts = mock(TIMESTAMP.class); when(ts.timestampValue()).thenReturn(new Timestamp(0l)); assertEquals(new Timestamp(0l), new OracleTimestampNormaliser().transform(ts)); }
protected Object fromOracleTimeClasses(Column column, Object data) { try { if (data instanceof TIMESTAMP) { data = ((TIMESTAMP) data).timestampValue(); } else if (data instanceof DATE) { data = ((DATE) data).timestampValue(); } else if (data instanceof TIMESTAMPTZ) { final TIMESTAMPTZ ts = (TIMESTAMPTZ)data; data = ZonedDateTime.ofInstant(ts.timestampValue(connection.connection()).toInstant(), ts.getTimeZone().toZoneId()); } else if (data instanceof TIMESTAMPLTZ) { // JDBC driver throws an exception // final TIMESTAMPLTZ ts = (TIMESTAMPLTZ)data; // data = ts.offsetDateTimeValue(connection.connection()); return null; } } catch (SQLException e) { throw new RuntimeException("Couldn't convert value for column " + column.name(), e); } return data; }
valueToConvert = ((TIMESTAMP)sourceObject).timestampValue(); } catch (SQLException exception) { throw DatabaseException.sqlException(exception);
valueToConvert = ((TIMESTAMP)sourceObject).timestampValue(); } catch (SQLException exception) { throw DatabaseException.sqlException(exception);