If you run this query in toad against an oracle DB:
select
to_char(TRUNC(sysdate, 'DAY'),'DAY') start_of_the_week
from dual;
Depending on the locale servers settings, you will get:
Sunday --EN, USA
Monday -- DE, GERMANY
This makes perfect sense and is all right.
If you do the exact same thing in Java through the OJDBC driver like this:
//....
Statement stm = JDBCConn.createStatement();
stm.execute("select to_char(TRUNC(sysdate, 'DAY'),'DAY') start_of_the_week from dual");
stm.getResultSet().next();
System.out.println(stm.getResultSet().getString("start_of_the_week"));
You will get Sunday or Monday back, but this is depending on your client local settings provided to the JVM you are running this statement. This means the answer you get back is no longer depending on the server local settings but on your client ones.
The fix is really easy, add
Locale.setDefault(new Locale("EN", "US", "WIN")); //or German etc..
Now to my actual question. Why would anyone think this is a good idea?!? Is there a situation why this makes sense? Is this a feature, because in my opinion this is a bug, or at least very bad design/concept.
Regards, Colin