I am attempting to set an oracle.sql.DATE value to pass to a stored procedure, but get some odd behaviour. Oracle 10.2 database, ojdbc7.jar (30 Jun 2014 version), JRE 1.8.0_31. Any thoughts?
a) DATE timeslot = DATE.fromText("20150518_0942","YYYYmmdd_hh24mi",null);
This causes a stack trace:
java.sql.SQLException: Invalid Oracle Date
at oracle.sql.LdxLibThin.ldxstd(LdxLibThin.java:1704)
at oracle.sql.DATE.fromText(DATE.java:993)
But:
DATE timeslot = DATE.fromText("20150518_09:42","YYYYmmdd_hh24:mi",null);
works fine. OK, so I seem to have a workaround, but why should I need the extra punctuation?
b) The following code may not produce a stack trace, but the time value is 9 hours behind the correct value:
Date timestamp = new Date();
java.text.SimpleDateFormat fmt = new java.text.SimpleDateFormat("yyyyMMdd_HHmm");
fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
DATE timeslot = DATE.fromText(fmt.format(timestamp),"YYYYmmdd_hh24mi",null);
System.out.println(timeslot.timeValue());
But run later in the day, it failed in the same way...