Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Precision error in converter property of <h:outputText> tag?

 
Fezekile Futhwa
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

I have a date object that I am trying to render using the <hutputText> tag. Since the object contains the full date/time string, I am formatting using the converter property(converter="javax.faces.DateTime").

But the resulting date is a day before the actual date! Tracing this I have found that the converter property calculates the day as starting from 00:00:01 and not 00:00:00 as is standard in Java.

I am curious to find out if this is an error or intentional behaviour?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I'm aware, the dateTime converter is employing only the standard conversion methods of the java.util.Date and Calendar classes.

One thing that bites a lot of people regarding the day, however, is that the internal date object itself is usually based on the GMT timezone (UTC). Which means that you'll usually have to localize it. This is extra fun in webapps, since the server could be on Beruit time (usually with a UTC system clock), one user could be in New York, and another could be in Shanghai. JSF doesn't attempt to deduce the client's timezone, so you have to provide it in the converter definition.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic