Error "java.text.ParseException: Unparseable date" due to Missing Trailing ".0" in Date String Retrieved from Database Using ResultSet.getString() on a Date/Timestamp Column (Doc ID 1144676.1)

Last updated on JULY 14, 2011

Applies to:

JDBC - Version: 11.2.0.1 and later   [Release: 11.2 and later ]
Information in this document applies to any platform.

Symptoms

You have noticed that when you retrieve a DATE field from the database using the method ResultSet.getString(), the date string is missing the trailing ".0"

The value returned when the date string is fetched with Oracle JDBC 11.2.0.1.0 is of the form:
2010-04-14 00:00:00’ 
whereas the value returned when the same is fetched with Oracle JDBC 11.1.0.7.0 or lower versions is of the form:
2010-04-14 00:00:00.0

This causes following exception when your Java code tries to parse the value to Date format:
java.text.ParseException: Unparseable date: "2010-05-31 00:00:00"
at java.text.DateFormat.parse(DateFormat.java:337)
at JdbcVersion.selectDate(JdbcVersion.java:70)
at JdbcVersion.main(JdbcVersion.java:23)

Changes

You have recently upgraded your Oracle JDBC driver to 11.2.0.1.0

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms