Sunday, August 26, 2012

Why JSF date always minus one day?

On last Wednesday, I was assigned a defect on a date issue. "Give me 1 hour to fix this." I answered to my supervisor. At the end of the day, my supervisor come to me, and I reply "The defect still haven't fix. =.=" ".

Here is the problem background. I have a JSF date input control. Whenever the form is submitted, the date value capture in the backing bean will becomes GST time zone, but my expectation is GMT time zone. Without doing a deep research on this will never know there is a design issue in JSF. JSF was using UTF as default time zone whereas I am using GMT time zone. To secure my date, I always have this code standing by:

Anyhow, the problem still has not fix. It took me another one day for the research. And finally I found a work around on this issue by setting the time zone in JVM server.

I was using WAS Liberty Profile server, how could I set the time zone in JVM?

WLP uses jvm.options file to specify additional start up option at the runtime. Its usage can be found in the README in wlp.install.dir. What I did was I put the jvm.options file in the same level as server.xml file, which is here -> {wlp.user.dir}/servers/.

In the jvm.options file, put this line and done.

No comments: