File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Precision error in converter property of <h:outputText> tag? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Precision error in converter property of <h:outputText> tag?" Watch "Precision error in converter property of <h:outputText> tag?" New topic

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

Fezekile Futhwa

Joined: Aug 03, 2011
Posts: 5

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

Joined: Jun 25, 2001
Posts: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Precision error in converter property of <h:outputText> tag?
It's not a secret anymore!