Wednesday, November 7, 2012

Oracle DB, SessionTimeZone, and Java

this SQL:

select SESSIONTIMEZONE from dual;

returns "Europe/Berlin"

(see )

"SESSIONTIMEZONE returns the time zone of the current session. The return type is a time zone offset (a character type in the format '[+|]TZH:TZM') or a time zone region name, depending on how the user specified the session time zone value in the most recent ALTER SESSION statement.... using the ORA_SDTZ environment variable "

The JDBC driver sets on the Session some date/time session parameters:

This code: 

import java.util.Calendar;

public class TimeZoneHelper {

    public static String getTimeZoneInfo()
      String result = "";
      Calendar now = Calendar.getInstance();
      result += now.getTimeZone();
      result += "_";
      result += now.getTime();
      return result;

returns this:

sun.util.calendar.ZoneInfo[id="Europe/Zurich",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=119,lastRule=java.util.SimpleTimeZone[id=Europe/Zurich,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]]_Wed Nov 07 22:45:56 CET 2012

I understand that there is a JVM property – Duser.timezone=’BLA’ 

or better still you can do
export TZ="IST"

on the shell prompt before you start WLS...

No comments: