I want to store the ZonedDateTime in TIMESTAMP WITH TIME ZONE datatype in oracle. If I am trying to store string directly as a String it throws not a valid month. then I found that I can convert it to the TIMESTAMPTZ in java then store because we need to convert the string to TIMESTAMPTZ and its throwing error.
String d = "2021-10-28 02:36:08.000000 +02:00";
TIMESTAMPTZ t = new TIMESTAMPTZ(con, d);
PreparedStatement ps = con.prepareStatement(query);
ps.setObject(1,t);
Error/stack trace:
Exception in thread "main" java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff] at java.sql.Timestamp.valueOf(Timestamp.java:251) at oracle.sql.TIMESTAMPTZ.toBytes(TIMESTAMPTZ.java:1919) at oracle.sql.TIMESTAMPTZ.<init>(TIMESTAMPTZ.java:253) at OracleSelectQuery.main(OracleSelectQuery.java:21)
Someone please look into this.