• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

MyFaces-Date/TimeZone Issue?

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.....
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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/
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<f:convertDateTime type="date" pattern="dd/MM/yyyy"/>
use this tag .I think it will work
 
Saloon Keeper
Posts: 24568
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic