Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MyFaces-Date/TimeZone Issue?

 
Amol Chavan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.....
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote my own datetime converter to get around this issue



Registered my convertor



Usage:

 
Amol Chavan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot,
Lynette Dawson
It really helped me and issue is resolved now.

Once again thanks for your help.
 
Venkat Sadasivam
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/
 
Bhaskar GR
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
use this tag .I think it will work
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18226
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pranjal mishra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic