You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mark <li...@mark-arnold.net> on 2006/05/03 09:40:41 UTC

Picking date format in localization using message-binding?

Hi,

is there an easy way to pick the desired date format when using the 
message-bindings?
In my example I have this in my html file:
<span jwcid="@Insert" 
value="ognl:messages.format('currentServerDateAndTime', new 
java.util.Date())">Current server date and time: June 26 2005</span>

The german resource entry looks like this:
currentServerDateAndTime=Aktuelle Serverzeit: {0}

The result is this:
Aktuelle Serverzeit: 03.05.06 00:09

This seems to be the short date format. What is the easiest way to 
change the date format to medium or long, so I can get the seconds, etc?

Thanks,

MARK

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Picking date format in localization using message-binding?

Posted by Mark <li...@mark-arnold.net>.
Cool idea...

So I guess I won't entirely get around writing a few lines of code...

Thanks for the ideas

MARK

Sam Gendler wrote:
> Or you could store the format string as a localized message, pass it
> to the SimpleDateFormat object, and format european dates for
> europeans, us dates for americans, etc.
>
> --sam
>
>
> On 5/3/06, Eric Fesler <er...@audaxis.com> wrote:
>> An easy way would be to use a page property to return the formatted date
>> string.
>>
>> Ex:
>> <span jwcid="@insert" 
>> value="ognl:messages.format('currentServerDateAndTime',
>> page.currentDateTime">Current server date and time</span>
>>
>> and on the page class/
>> public String getCurrentDateTime() {
>>     SimpleDateFormat df = new SimpleDateFormat("MMMM d yyyy");
>>     return df.format(new java.util.Date());
>> }
>>
>>
>> --ERic
>>
>> On Wednesday 03 May 2006 09:40, Mark wrote:
>> > Hi,
>> >
>> > is there an easy way to pick the desired date format when using the
>> > message-bindings?
>> > In my example I have this in my html file:
>> > <span jwcid="@Insert"
>> > value="ognl:messages.format('currentServerDateAndTime', new
>> > java.util.Date())">Current server date and time: June 26 2005</span>
>> >
>> > The german resource entry looks like this:
>> > currentServerDateAndTime=Aktuelle Serverzeit: {0}
>> >
>> > The result is this:
>> > Aktuelle Serverzeit: 03.05.06 00:09
>> >
>> > This seems to be the short date format. What is the easiest way to
>> > change the date format to medium or long, so I can get the seconds, 
>> etc?
>> >
>> > Thanks,
>> >
>> > MARK
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Picking date format in localization using message-binding?

Posted by Sam Gendler <sg...@ideasculptor.com>.
Or you could store the format string as a localized message, pass it
to the SimpleDateFormat object, and format european dates for
europeans, us dates for americans, etc.

--sam


On 5/3/06, Eric Fesler <er...@audaxis.com> wrote:
> An easy way would be to use a page property to return the formatted date
> string.
>
> Ex:
> <span jwcid="@insert" value="ognl:messages.format('currentServerDateAndTime',
> page.currentDateTime">Current server date and time</span>
>
> and on the page class/
> public String getCurrentDateTime() {
>     SimpleDateFormat df = new SimpleDateFormat("MMMM d yyyy");
>     return df.format(new java.util.Date());
> }
>
>
> --ERic
>
> On Wednesday 03 May 2006 09:40, Mark wrote:
> > Hi,
> >
> > is there an easy way to pick the desired date format when using the
> > message-bindings?
> > In my example I have this in my html file:
> > <span jwcid="@Insert"
> > value="ognl:messages.format('currentServerDateAndTime', new
> > java.util.Date())">Current server date and time: June 26 2005</span>
> >
> > The german resource entry looks like this:
> > currentServerDateAndTime=Aktuelle Serverzeit: {0}
> >
> > The result is this:
> > Aktuelle Serverzeit: 03.05.06 00:09
> >
> > This seems to be the short date format. What is the easiest way to
> > change the date format to medium or long, so I can get the seconds, etc?
> >
> > Thanks,
> >
> > MARK
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Picking date format in localization using message-binding?

Posted by Eric Fesler <er...@audaxis.com>.
An easy way would be to use a page property to return the formatted date 
string.

Ex:
<span jwcid="@insert" value="ognl:messages.format('currentServerDateAndTime', 
page.currentDateTime">Current server date and time</span>

and on the page class/
public String getCurrentDateTime() {
    SimpleDateFormat df = new SimpleDateFormat("MMMM d yyyy");
    return df.format(new java.util.Date());
}


--ERic

On Wednesday 03 May 2006 09:40, Mark wrote:
> Hi,
>
> is there an easy way to pick the desired date format when using the
> message-bindings?
> In my example I have this in my html file:
> <span jwcid="@Insert"
> value="ognl:messages.format('currentServerDateAndTime', new
> java.util.Date())">Current server date and time: June 26 2005</span>
>
> The german resource entry looks like this:
> currentServerDateAndTime=Aktuelle Serverzeit: {0}
>
> The result is this:
> Aktuelle Serverzeit: 03.05.06 00:09
>
> This seems to be the short date format. What is the easiest way to
> change the date format to medium or long, so I can get the seconds, etc?
>
> Thanks,
>
> MARK
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org