dev@javaserverfaces.java.net

Re: BUG: DateTimeConverter or some flaky JDK stuff ?

From: Matthias Wessendorf <matzew_at_apache.org>
Date: Thu, 2 Jul 2009 11:01:55 +0200

here is a potential fix.

https://issues.apache.org/jira/browse/TRINIDAD-1524

basically if the pattern (e.g. ) requires a whitespace at the end,
the converter should honor that ...

Do you want me to file a SPEC bug ?

(no, I am only "fixing" that in the Trinidad code, so far. Not in MyFaces...)

-Matthias

On Wed, Jul 1, 2009 at 7:43 AM, Matthias Wessendorf<matzew_at_apache.org> wrote:
> Hi,
>
> following snippet:
>       <h:form>
>         <h:messages/>
>         <h:inputText value="#{input.date}" immediate="true">
>           <f:convertDateTime type="both" timeStyle="full"
>           timeZone="America/New_York"
>           pattern="dd.MM.yyyy HH:mm' Uhr '"
>           locale="de"
>           />
>         </h:inputText>
>         <h:commandButton value="Submit" type="submit"/>
>       </h:form>
>
> and now, enter this (in your mind remove the |):
> |30.06.2009 13:10 Uhr |
>
> the underlying parse() on (Simple)DateFormat strips the empty space away.
> And it fails.
>
> On rendering (getAsString) the rendered result is this:
> |30.06.2009 13:10 Uhr |
>
> again, notice the last empty string.
>
> Now, doing this, with vanilla Java:
>
>     DateFormat df =
> DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.FULL,
> Locale.GERMAN);
>     df.setTimeZone(TimeZone.getTimeZone ("America/New_York"));
>         SimpleDateFormat sdf = (SimpleDateFormat)df;
>         sdf.applyPattern("dd.MM.yyyy HH:mm' Uhr '");
>     System.out.println(df.format(new Date()));
>             sdf.parse("30.06.09 11:43 Uhr");
>
>
> The PARSE fails, as there is no " " after the German word Uhr.
> The String, returned by this line: df.format(new Date()) actually
> has one " " at the very end...
>
> any ideas ?
>
> Sure I f**k our Trinidad converter by checking for endsWith("Uhr"),
> but that is a little bit sucky... :-)
>
> -Matthias
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>



-- 
Matthias Wessendorf
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf