NLS_DATE_FORMAT with JDBC
<p>I tried to set NLS_DATE_FORMAT inside jdbc, it didn't seem to have any effect.
My code :</p>
<pre><code>//...
Connection conn = ods.getConnection();
Statement stat = conn.createStatement();

stat.execute(&quot;alter session set NLS_DATE_FORMAT='YYYY-DD-MM'&quot;);
ResultSet rs = stat.executeQuery(&quot;select date_column from test_table&quot;);

System.out.println(rs.getString(1));   // *** new format not effective here ***
//...
    
</code></pre>
<p>After some reading. I understand that NLS_DATE_FORMAT is hard coded in JDBC Drivers. is this correct ? conclusion made from this :</p>
<blockquote>
<p>Language and Territory</p>
<p>The Thin driver obtains language and territory settings (NLS_LANGUAGE and NLS_TERRITORY) from the Java locale in the JVM user.language property. The date format (NLS_DATE_FORMAT) is set according to the territory setting.</p>
</blockquote>
<p>So I tried this :</p>
<pre><code>Locale.setDefault(new Locale(&quot;en&quot;, &quot;US&quot;));
Connection conn = ods.getConnection();
Statement stat = conn.createStatement();

ResultSet rs = stat.executeQuery(&quot;select date_column from test_table&quot;);

System.out.println(rs.getString(1));   // *** JVM format not effective here 
</code></pre>
<p>But it's not working. Instead of getting something like</p>
<pre><code>10-OCT-15 (NLS_DATE_FORMAT for US = 'DD-MON-RR')
</code></pre>
<p>I get</p>
<pre><code>2015-10-10 00:00:00.0
</code></pre>
<p>Using ORACLE 11g, Oracle jdbc drive 12.1, java 8</p>