Usage Of SimpleDateFormat / DateFormat (Doc ID 340956.1)

Last updated on SEPTEMBER 01, 2014

Applies to:

JDBC - Version 10.1.0.5 and later
Information in this document applies to any platform.

Symptoms

Obtaining values for a date column from Oracle Database returns these dates always in the following format:
YYYY-MM-DD HH:MM:SS.S
The code being used looks like:
  ...
  boolean tf = stmt.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MM-YYYY'");
  ResultSet rs = stmt.executeQuery("SELECT SYSDATE FROM DUAL");
  while(rs.next()) {
    System.out.println("Got: " + rs.getDate(1) );
  }
  ...

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