| Author |
MyFaces-Date/TimeZone Issue?
|
Amol Chavan
Greenhorn
Joined: Sep 04, 2005
Posts: 28
|
|
Hi Ranchers, I am having an issue with date display in an JSF application say 31/12/2006 date is being displayed as 30/12/2006 while in DataBase it is stil 31/12/2006. what may be an issue? is it an issue related to MyFaces? I got a solution to set Environment variable: CATALINA_OPTS= -Duser.timezone = GMT while starting server (Tomcat5.0) but I can ask client to do this each time at the server start-up. So how to set up this var for Tomcat as well as JBoss because this variable solves the problem. Mycode snippet: <t:inputText styleClass="inputdis" id="txtLrs11" value="#{scheduleBean.datScheduleDate11}" readonly="true"> <f:convertDateTime timeZone="#{policyBean.timezone}" pattern="MM/dd/yyyy"/> </t:inputText> --------------- in the above code: policyBean.timezone is to set timezone to "GMT+10)" bcos in MyEclipse I don know how to set CATALINA_OPTS. its working fine but then while saving it to DataBase it is saving as 30/12/2006 instead of 31/12/2006. Please Help me. Thanks in Advance.....
|
Thanks n Regards,<br />Amol
|
 |
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
|
|
I wrote my own datetime converter to get around this issue Registered my convertor Usage:
|
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
|
 |
Amol Chavan
Greenhorn
Joined: Sep 04, 2005
Posts: 28
|
|
Thanks a lot, Lynette Dawson It really helped me and issue is resolved now. Once again thanks for your help.
|
 |
Venkat Sadasivam
Ranch Hand
Joined: May 10, 2008
Posts: 139
|
|
To resolve the timezone and date pattern issue, an alternative approach can be found here. http://venkatsadasivam.wordpress.com/2008/07/08/jsf-default-timezone-and-date-pattern/
|
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ”<br>
-Martin Fowler
|
 |
Bhaskar GR
Greenhorn
Joined: Jun 13, 2008
Posts: 28
|
|
<f:convertDateTime type="date" pattern="dd/MM/yyyy"/> use this tag .I think it will work
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14491
|
|
|
This is a really irritating property of the JSF datetime converter. It defaults to translating to GMT and the only way to use a local timezone is to either explicitly code the timezone (instead of depending on user locale info) or to use one of the workarounds people have listed above.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
pranjal mishra
Greenhorn
Joined: Jan 08, 2009
Posts: 21
|
|
|
Well I was facing the same issue as Amol had, but I removed the timeZone attribute from the <f:convertDateTime /> tag, and guess what I got it on the track.
|
SCJP 1.5(95%)
|
 |
 |
|
|
subject: MyFaces-Date/TimeZone Issue?
|
|
|