• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF/RichFaces calendar; value loses one day

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

Has anyone experienced an issue wherein a date that is submitted with a datePattern of "DD-MON-YYYY" reverts to the previous day when modifying using a rich:calendar?

For example, I have a rich:calendar wherein a date is inputted on a JSF/Seam 2.0GA form. The date submits appropriately. When I then edit this date, the rich:calendar and inputText think the date is now one day prior to the previously entered date. This problem persists...so if I submit the form with the new date (-1) and repeat the process, I will lose one day each time.

I'm starting to suspect this has to do with the timezone of the time (since there is no time in the datePattern)? Has anyone experienced this before? It also happens during the JSF validation lifecycle; so, for example, if another field on the forms has a validation error, the date input textbox will lose a day.


Thanks for your time.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I encountered this Time Zone problem but using the component of ICEFACES. Our workaround was to implement a custom converter that simply set the appropriate Time Zone.

I hope this experience helps.
 
Saloon Keeper
Posts: 27764
196
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
The timezone in java.util.Date is GMT, and yes it's a royal pain. Especially since there's no way to globally environmentally set the effective time zone for all date/time tags on a JSF page.

Which means that they all are either displayed in GMT or you have to manually set each and every one to the preferred zone. Which could be especially annoying if you have a web application with users in local timezones and want to display relative to their local times.
 
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok I have different experience here. For me date works fine but not the timer control, here is parallel thread going on.

https://coderanch.com/t/61302/oa/RichCalendar-Timer-control-SEAM

As soon as I will try to change the time RichCalendar disappers and it doesn't populate any value in input box.

However everything works fine as I can see online Ajax Calendar works perfectly:
web page
 
Chris Simons
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the responses, all. So you are thinking it is a timezone issue after all? What about when you set the datePattern on the rich:calendar to not include any time? It shouldn't even keep track of the time or time zone, right? I think it still does, though, as when I just use "dd-mon-yyyy" it always shows "20:00 GMT" for the time.

With that in mind, I can't understand why it would decrease the day - since that would be a big jump in time.
 
Chris Simons
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, I am using a custom converter for our <f:convertDateTime> calls, which we use everywhere that we display or input a date.

Still stuck on this issue. Very little help from RichFaces developers.
 
Jerwin Louise Uy
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Our implementation of the custom converter simply extended javax.faces.convert.DateTimeConverter


[ August 14, 2008: Message edited by: Jerwin Louise Uy ]
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solution might popup from here.
 
Chris Simons
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am doing something similar; although I did not write a converter for java.util.Date, I am using a binding method for <f:convertDateTime> and also using some EL to perform a custom datePattern on <rich:calendar>.

<rich:calendar ...
datePattern="#{messages['output.datePattern']}">
<f:convertDateTime binding="#{globalUtil.convertDate}"/>
</rich:calendar>

"convertDate" is as follows:
Locale defaultLocale = Locale.US;
TimeZone defaultTimeZone = TimeZone.getTimeZone("GMT");

convertDate.setPattern(this.getProp("output.datePattern"));
convertDate.setDateStyle(this.getProp("output.dateStyle"));
convertDate.setLocale(defaultLocale );
convertDate.setDateStyle(this.getProp("output.dateStyle"));
convertDate.setType("date");
convertDate.setTimeZone(defaultTimeZone);


But perhaps this just isn't quite enough?
 
Venkat Sadasivam
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
TimeZone defaultTimeZone = TimeZone.getTimeZone("GMT");

The above line should be changed as below

TimeZone defaultTimeZone = TimeZone.getDefault();
 
Chris Simons
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks I'll give that a try and see if it helps.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was struggling wit it too.
In the end this worked for me:

<rich:calendar datePattern="dd-MM-yyyy" timeZone="#{pickersReport.timeZone}" locale="#{facesContext.viewRoot.locale}" value="#{pickersReport.fromDate}"/>

<param name="fromDate" value="#{pickersReport.fromDate}" converterId="org.jboss.seam.ui.DateTimeConverter" />

The time part was not passed on though. (Of course WITH HH:mm in the datePattern)
 
Jignesh Patel
Ranch Hand
Posts: 686
Mac
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Wilfred Rosdorff:

The time part was not passed on though. (Of course WITH HH:mm in the datePattern)



Yup thats' a bug. And because of that I have decided not to use converter but then to take time as a seperate string object and then convert again as a time.
 
Chris Simons
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, has anyone submitted this to RichFaces JIRA? Not that they'll ever fix it...; well, we can hope that they will.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Usually you can set this the timezone in your application server's startup script. I noticed this with my JBoss server when my logs were always 2 hours behind. I'm not sure about the other application servers but with JBoss you can go to %JBOSS_HOME%/bin/run.bat (or run.sh for Linux) and edit the file. Search for 'GMT' and then fix the timezone there.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic