I'm trying to insert a date into a db oracle column using offsetdatetime, but I'm having some problem. With The last solution I've tried, I would able to write the date in the db, but the date is not correct "08-JAN-70 04:05:02".
private static final String INSERT_QUERY = "INSERT INTO TABLENAME (N_ID_INVOICE, "
+ "N_ID_NOTS_SDI, "
+ "N_TYPE_NOTS,"
+ "N_DATE_NOTS, "
+ "N_STATE_NOTS, "
+ "N_DES_NOTS, "
+ "N_XML_NOTS)"
+ " values "
+ "(?,?,?,?,?,?,convert(?,'WE8MSWIN1252','UTF8'))";
@Override
public synchronized void insertNotis(Connection conn,String invoiceUID, String invoiceNotifUID, OffsetDateTime utcDate, String notificationType,
String note, String typeNots,Clob notifSdiClob) throws SQLException
{
Timestamp t=new Timestamp(utcDate.getNano());
PreparedStatement pstmt=null;
pstmt=conn.prepareStatement(INSERT_QUERY);
pstmt.setString(1, invoiceUID);
pstmt.setString(2, invoiceNotifUID);
pstmt.setString(3, typeNots);
pstmt.setTimestamp(4, t);
pstmt.setString(5, notificationType);
pstmt.setString(6, note);
pstmt.setClob(7, notifSdiClob);
pstmt.execute();
}
Convert OffsetDateTime to UTC Timestamp I saw this solution, but I can't follow it because, for this project, I must only use org.threeten.bp.OffsetDateTime.