This is exactly the same question as Default JDBC date format when reading date as a string from ResultSet, but that question was never actually answered as such; people just offered alternative ways to write the code.
I'm specifically asking if anyone knows where the default conversion format is specified, and if it is defined by a JDBC spec somewhere, or just left up to the individual JDBC driver. If the latter, then an additional question of how does Oracle 10g JDBC do this?
** Added 15-Jan:
Sorry, I thought the question was sufficiently clear, but apparently not. I am not trying to retrieve a date value from a database, and have no need for suggestions on ways to do that.
I do not think this is a duplicate of the referenced question, which is why I asked a separate question here. Whilst the title is the pretty much same, the referenced question (regardless of what the OP intended) has been answered with alternative approaches for retrieving a date value from a database, which is not what I wish to know.
Cheers,
Ok, so tracing through the JDBC code, it looks like the Oracle driver hard-codes its own formatting:
int k = (((bytes[0 + j] & 255) - 100) * 100 + (bytes[1 + j] & 255)) - 100;
String s = k + "-" + toStr(bytes[2 + j])
+ "-" + toStr(bytes[3 + j])
+ " " + toStr(bytes[4 + j] - 1)
+ ":" + toStr(bytes[5 + j] - 1)
+ ":" + toStr(bytes[6 + j] - 1)
+ ".0";
So from this, I'm guessing that:
I'm assuming these because different implementations return different formats. Of course, it is still possible that this format is mandated somewhere in a JDBC spec, and some implementations are non-conformant, but that seems unlikely. I certainly couldn't find any references to this in a JDBC spec (but that doesn't mean they are not there somewhere!).
However, the key point as far as I am concerned, is that the format is hard-coded in the library and not overridable by any environment or other settings, but also won't change across systems as long as the driver library version remains the same.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments