Where is the date format specified when reading a date as a string from JDBC ResultSet

Barney

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,

Barney

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:

  1. This behaviour is not specified anywhere in any JDBC spec.
  2. Each driver library may return any format it likes.

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Where is the date format specified when reading a date as a string from JDBC ResultSet

From Dev

Reading date from string format

From Dev

JDBC format ResultSet as tabular string?

From Dev

Get year of datetime where date is not fully specified with JDBC

From Dev

Getting date from unknown Date format string

From Dev

Getting date from unknown Date format string

From Dev

How to update date in Date format to a resultset?

From Dev

Reading string from CSV and parsing to date

From Dev

PHP date_format(): How to format date from string value

From Dev

ParseException When Reading Date from File

From Dev

Split a Specified string into Date

From Dev

Change date format in C# when reading from database and setting to label

From Dev

How to get Date from a resultSet

From Dev

How to change format of a date from dd/mm/yyyy to MM/dd/yyyy where date is already converted from string?

From Dev

UWP - How do I convert date from calendar date picker to specified date format

From Dev

Convert date to specified format linux

From Dev

Format string date into date object

From Dev

format string from Date.getTime()

From Dev

Checking Date format from a string in C#

From Dev

Python format date string from postgresql db

From Dev

How to fetch date from string format

From Dev

Extract different format date from a string in Python

From Dev

automatically detect date format from string in linux?

From Dev

Transform string to date format ( from week number )

From Dev

how to extract date format from a string oracle

From Dev

Conversion error from date time to string format

From Dev

phpexcel date is reading wrong format

From Dev

JavaScript New Date from a 12 hour format date and time string

From Dev

Convert date from weird string to date in format day month and year

Related Related

  1. 1

    Where is the date format specified when reading a date as a string from JDBC ResultSet

  2. 2

    Reading date from string format

  3. 3

    JDBC format ResultSet as tabular string?

  4. 4

    Get year of datetime where date is not fully specified with JDBC

  5. 5

    Getting date from unknown Date format string

  6. 6

    Getting date from unknown Date format string

  7. 7

    How to update date in Date format to a resultset?

  8. 8

    Reading string from CSV and parsing to date

  9. 9

    PHP date_format(): How to format date from string value

  10. 10

    ParseException When Reading Date from File

  11. 11

    Split a Specified string into Date

  12. 12

    Change date format in C# when reading from database and setting to label

  13. 13

    How to get Date from a resultSet

  14. 14

    How to change format of a date from dd/mm/yyyy to MM/dd/yyyy where date is already converted from string?

  15. 15

    UWP - How do I convert date from calendar date picker to specified date format

  16. 16

    Convert date to specified format linux

  17. 17

    Format string date into date object

  18. 18

    format string from Date.getTime()

  19. 19

    Checking Date format from a string in C#

  20. 20

    Python format date string from postgresql db

  21. 21

    How to fetch date from string format

  22. 22

    Extract different format date from a string in Python

  23. 23

    automatically detect date format from string in linux?

  24. 24

    Transform string to date format ( from week number )

  25. 25

    how to extract date format from a string oracle

  26. 26

    Conversion error from date time to string format

  27. 27

    phpexcel date is reading wrong format

  28. 28

    JavaScript New Date from a 12 hour format date and time string

  29. 29

    Convert date from weird string to date in format day month and year

HotTag

Archive