Skip to main content

Tips on configuring timezone for a fusion web application

Update:
#{adfFacesContext.timeZone.ID} does not bring the browser timezone any more(this has been turned off in Trinidad layer sometime back and it will display time zone of the underlying JRE instead). this is because there are no fool proof mechanism available to identity the timezone settings for the client browser. The below blog post is no longer valid if the requirement is to read timezone set for the end-user machine/browser.

You can set the timezone for a fusion web application using the time-zone element in trinidad-config.xml
Doc says:
Apache Trinidad will attempt to default the time zone to the time zone used by the client browser. If needed, you can use an EL expression that evaluates to a TimeZone object. This value is used by org.apache.myfaces.trinidad.converter.DateTimeConverter while converting strings to Date.

Please note that the above configuration is valid only for the view layer. ADF BC layer would use the time zone configured in the adf-config.xml. And this value can be retrieved by using oracle.jbo.common.DefLocaleContext.
e.g: DefLocaleContext.getInstance().getUserTimeZone();

How to make these two layers to work on same 'timezone' ?

Yes, you can do that using EL for configuring timezone in adf-config.xml. Please see the EL #{adfFacesContext.timeZone.ID} used in the following configuration. This refers the timezone used by the view layer.
#{adfFacesContext.timeZone.ID} => AdfFacesContext.getCurrentInstance().getTimeZone().getID();
In effect, this expression help us to pass the timezone from the view layer to the business service layer in a smart way.
<?xml version="1.0" encoding="windows-1252" ?>
<adf-config xmlns="http://xmlns.oracle.com/adf/config"
 ......
<user-timezone-config xmlns="http://xmlns.oracle.com/adf/usertimezone/config">
<user-timezone expression="#{adfFacesContext.timeZone.ID}"/>
</user-timezone-config>

Comments

Bali said…
I think this gives server timezone always. I configured adf-config.xml with above code.
Jobinesh said…
Sorry, I can see this working in my sample. Please pass me a test case if you have any, will follow it up
Anonymous said…
#{adfFacesContext.timeZone.ID} expression always evaluates to server timezone right? Do we need to capture the client timezone through a javascript function and pass that value to the expression below?
<user-timezone expression=
Jobinesh said…
#{adfFacesContext.timeZone.ID} does not bring the browser timezone any more(this has been turned off in Trinidad layer sometime back and it will display time zone of the underlying JRE instead). this is because there are no fool proof mechanism available to identity the timezone settings for the client browser.
Anonymous said…
Hello,

How to display the user login time using browser's timezone in adf?
Prakash said…
Hi Jobinesh,
I am a bit new to ADF.
Could you please tell me what is the correct location path to this adf-config.xml. I tried to search in my existing view and there were many adf-config.xml that were existing.

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!