Skip to main content

Error messages when converting time with f:convertDateTime

1 reply [Last post]
vetler
Offline
Joined: 2010-05-25

Hi,

I have problem with f:convertDateTime, that it seems to use the error message javax.faces.converter.DateTimeConverter.DATE_detail when I convert time (i.e. it should use javax.faces.converter.DateTimeConverter.TIME_detail).

The issue, I'm guessing, is that I use a pattern, and thus it does not know if it's a date or a time. This is what I'm trying:

"timePattern" is "hh.mm".

Even though type="time" is specified, it still uses the DATE_detail error message. Is this an bug or is my assumption that it should use the TIME_detail error message wrong?

TIA,
Vetle

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vetler
Offline
Joined: 2010-05-25

http://stackoverflow.com/questions/3615458/date-error-when-converting-ti...

[i]Unfortunately, that's also what the DateTimeConverter javadoc is telling. Here's an extract of relevance:

If a pattern has been specified, its syntax must conform the rules specified by java.text.SimpleDateFormat. Such a pattern will be used to parse, and the type, dateStyle, and timeStyle properties will be ignored.

I must however admit that the JSF boys had to specify it explicitly in the f:convertDateTime pdldoc as well. It's not obvious from there. I'd report an issue to the JSF boys to get them to clarify this part.

To get it to work, your best bet is either not relying on the pattern, but on type, dateStyle and timeStyle (and the locale) instead, or create a custom date time converter which extends DateTimeConverter and overrides the methods accordingly.[/i]