You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jon Pearson <Jo...@sixnet.com> on 2009/05/06 19:10:51 UTC

Date/time formatting

If I wanted to output a date/time value in the user's locale, is there a
simple way to do that? I see there is a <date> tag which would be
helpful for getting the date format correct without manually specifying
it, but what about a similar <time> tag? Am I going to need to manually
specify the standard date format as "M/D/y h/mm/ss a" for US English,
and just require any translation to specify its own?

Thanks,
~Jonathan

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


RE: Date/time formatting

Posted by Jon Pearson <Jo...@sixnet.com>.
Nevermind, I was reading it wrong; when using those format strings, they belong in <s:text ...> tags, not in <s:date ...>. Sorry, and thanks! 

> -----Original Message-----
> From: Jon Pearson 
> Sent: Friday, May 08, 2009 7:53 AM
> To: Struts Users Mailing List
> Subject: RE: Date/time formatting
> 
> I've looked at that, but it doesn't explain when format.time 
> is used. I can see that format.date gets used when formatting 
> dates using the <s:date ...> tag, but since there is no 
> <s:time ...> tag, when is format.time used?
> 
> > -----Original Message-----
> > From: Rene Gielen [mailto:gielen@it-neering.net]
> > Sent: Thursday, May 07, 2009 9:03 PM
> > To: Struts Users Mailing List
> > Subject: Re: Date/time formatting
> > 
> > 
> http://struts.apache.org/2.1.6/docs/formatting-dates-and-numbers.html
> > 
> > Jon Pearson schrieb:
> > > Right, but I don't want to specify the format explicitely,
> > since it should depend on the localization of the browser. 
> > But when I don't specify it, I don't get the time included in the 
> > output. Is there a way to get both?
> > >  
> > > 
> > >> -----Original Message-----
> > >> From: Martin Gainty [mailto:mgainty@hotmail.com]
> > >> Sent: Wednesday, May 06, 2009 2:20 PM
> > >> To: Struts Users Mailing List
> > >> Subject: RE: Date/time formatting
> > >>
> > >>
> > >> you can also use the Struts date tag <%@taglib prefix="s" 
> > >> uri="/struts-tags" %> <s:date name="person.birthday" 
> > >> format="dd/MM/yyyy" /> if no format is specified format 
> defaults to 
> > >> DateFormat.MEDIUM (in US = MMM d, 
> > >> yyyy)http://struts.apache.org/2.0.14/docs/date.html
> > >>
> > >> HTH
> > >> Martin
> > >> ______________________________________________
> > >> Disclaimer and Confidentiality/Verzicht und 
> > >> Vertraulichkeitanmerkung/Note de déni et de confidentialité This 
> > >> message is confidential. If you should not be the intended
> > receiver,
> > >> then we ask politely to report. Each unauthorized forwarding or 
> > >> manufacturing of a copy is inadmissible. This message
> > serves only for
> > >> the exchange of information and has no legal binding
> > effect. Due to
> > >> the easy manipulation of emails we cannot take 
> responsibility over 
> > >> the the contents.
> > >> Diese Nachricht ist vertraulich. Sollten Sie nicht der 
> vorgesehene 
> > >> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede 
> > >> unbefugte Weiterleitung oder Fertigung einer Kopie ist
> > unzulaessig. 
> > >> Diese Nachricht dient lediglich dem Austausch von
> > Informationen und
> > >> entfaltet keine rechtliche Bindungswirkung. Aufgrund der 
> leichten 
> > >> Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den 
> > >> Inhalt uebernehmen.
> > >> Ce message est confidentiel et peut être privilégié. Si
> > vous n'êtes
> > >> pas le destinataire prévu, nous te demandons avec bonté que pour 
> > >> satisfaire informez l'expéditeur. N'importe quelle diffusion non 
> > >> autorisée ou la copie de ceci est interdite. Ce message sert à 
> > >> l'information seulement et n'aura pas n'importe quel effet
> > légalement
> > >> obligatoire. Étant donné que les email peuvent facilement
> > être sujets
> > >> à la manipulation, nous ne pouvons accepter aucune 
> responsabilité 
> > >> pour le contenu fourni.
> > >>
> > >>
> > >>
> > >>
> > >>> Date: Wed, 6 May 2009 14:04:33 -0400
> > >>> From: Terry.Gardner@Sun.COM
> > >>> Subject: Re: Date/time formatting
> > >>> To: user@struts.apache.org
> > >>>
> > >>> java.text.SimpleDateFormat formats a java.util.Date
> > according to a
> > >>> locale and a patter specified by the client.
> > >>>
> > >>> On May 6, 2009, at 1:10 PM, Jon Pearson wrote:
> > >>>
> > >>>> If I wanted to output a date/time value in the user's 
> locale, is 
> > >>>> there a simple way to do that? I see there is a <date> 
> tag which 
> > >>>> would be helpful for getting the date format correct without 
> > >>>> manually specifying it, but what about a similar <time>
> > tag? Am I
> > >>>> going to need to manually specify the standard date
> > >> format as "M/D/y
> > >>>> h/mm/ss a" for US English, and just require any translation to 
> > >>>> specify its own?
> > >>>>
> > >>>> Thanks,
> > >>>> ~Jonathan
> > >>>>
> > >>>>
> > >> 
> > --------------------------------------------------------------------
> > >>>> - To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >>>> For additional commands, e-mail: user-help@struts.apache.org
> > >>>>
> > >> _________________________________________________________________
> > >> Hotmail® has ever-growing storage! Don't worry about
> > storage limits.
> > >> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM
> > >> _WL_HM_Tutorial_Storage1_052009
> > >>
> > > 
> > > 
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > > 
> > 
> > --
> > René Gielen
> > IT-Neering.net
> > Saarstrasse 100, 52062 Aachen, Germany
> > Tel: +49-(0)241-4010770
> > Fax: +49-(0)241-4010771
> > http://twitter.com/rgielen
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

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


RE: Date/time formatting

Posted by Jon Pearson <Jo...@sixnet.com>.
I've looked at that, but it doesn't explain when format.time is used. I can see that format.date gets used when formatting dates using the <s:date ...> tag, but since there is no <s:time ...> tag, when is format.time used?

> -----Original Message-----
> From: Rene Gielen [mailto:gielen@it-neering.net] 
> Sent: Thursday, May 07, 2009 9:03 PM
> To: Struts Users Mailing List
> Subject: Re: Date/time formatting
> 
> http://struts.apache.org/2.1.6/docs/formatting-dates-and-numbers.html
> 
> Jon Pearson schrieb:
> > Right, but I don't want to specify the format explicitely, 
> since it should depend on the localization of the browser. 
> But when I don't specify it, I don't get the time included in 
> the output. Is there a way to get both?
> >  
> > 
> >> -----Original Message-----
> >> From: Martin Gainty [mailto:mgainty@hotmail.com]
> >> Sent: Wednesday, May 06, 2009 2:20 PM
> >> To: Struts Users Mailing List
> >> Subject: RE: Date/time formatting
> >>
> >>
> >> you can also use the Struts date tag
> >> <%@taglib prefix="s" uri="/struts-tags" %> <s:date 
> >> name="person.birthday" format="dd/MM/yyyy" /> if no format is 
> >> specified format defaults to DateFormat.MEDIUM (in US = MMM d, 
> >> yyyy)http://struts.apache.org/2.0.14/docs/date.html
> >>
> >> HTH
> >> Martin
> >> ______________________________________________
> >> Disclaimer and Confidentiality/Verzicht und 
> >> Vertraulichkeitanmerkung/Note de déni et de confidentialité This 
> >> message is confidential. If you should not be the intended 
> receiver, 
> >> then we ask politely to report. Each unauthorized forwarding or 
> >> manufacturing of a copy is inadmissible. This message 
> serves only for 
> >> the exchange of information and has no legal binding 
> effect. Due to 
> >> the easy manipulation of emails we cannot take responsibility over 
> >> the the contents.
> >> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene 
> >> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede 
> >> unbefugte Weiterleitung oder Fertigung einer Kopie ist 
> unzulaessig. 
> >> Diese Nachricht dient lediglich dem Austausch von 
> Informationen und 
> >> entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten 
> >> Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den 
> >> Inhalt uebernehmen.
> >> Ce message est confidentiel et peut être privilégié. Si 
> vous n'êtes 
> >> pas le destinataire prévu, nous te demandons avec bonté que pour 
> >> satisfaire informez l'expéditeur. N'importe quelle diffusion non 
> >> autorisée ou la copie de ceci est interdite. Ce message sert à 
> >> l'information seulement et n'aura pas n'importe quel effet 
> légalement 
> >> obligatoire. Étant donné que les email peuvent facilement 
> être sujets 
> >> à la manipulation, nous ne pouvons accepter aucune responsabilité 
> >> pour le contenu fourni.
> >>
> >>
> >>
> >>
> >>> Date: Wed, 6 May 2009 14:04:33 -0400
> >>> From: Terry.Gardner@Sun.COM
> >>> Subject: Re: Date/time formatting
> >>> To: user@struts.apache.org
> >>>
> >>> java.text.SimpleDateFormat formats a java.util.Date 
> according to a 
> >>> locale and a patter specified by the client.
> >>>
> >>> On May 6, 2009, at 1:10 PM, Jon Pearson wrote:
> >>>
> >>>> If I wanted to output a date/time value in the user's locale, is 
> >>>> there a simple way to do that? I see there is a <date> tag which 
> >>>> would be helpful for getting the date format correct without 
> >>>> manually specifying it, but what about a similar <time> 
> tag? Am I 
> >>>> going to need to manually specify the standard date
> >> format as "M/D/y
> >>>> h/mm/ss a" for US English, and just require any translation to 
> >>>> specify its own?
> >>>>
> >>>> Thanks,
> >>>> ~Jonathan
> >>>>
> >>>>
> >> 
> --------------------------------------------------------------------
> >>>> - To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>> For additional commands, e-mail: user-help@struts.apache.org
> >>>>
> >> _________________________________________________________________
> >> Hotmail® has ever-growing storage! Don't worry about 
> storage limits.
> >> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM
> >> _WL_HM_Tutorial_Storage1_052009
> >>
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> 
> --
> René Gielen
> IT-Neering.net
> Saarstrasse 100, 52062 Aachen, Germany
> Tel: +49-(0)241-4010770
> Fax: +49-(0)241-4010771
> http://twitter.com/rgielen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

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


Re: Date/time formatting

Posted by Rene Gielen <gi...@it-neering.net>.
http://struts.apache.org/2.1.6/docs/formatting-dates-and-numbers.html

Jon Pearson schrieb:
> Right, but I don't want to specify the format explicitely, since it should depend on the localization of the browser. But when I don't specify it, I don't get the time included in the output. Is there a way to get both?
>  
> 
>> -----Original Message-----
>> From: Martin Gainty [mailto:mgainty@hotmail.com] 
>> Sent: Wednesday, May 06, 2009 2:20 PM
>> To: Struts Users Mailing List
>> Subject: RE: Date/time formatting
>>
>>
>> you can also use the Struts date tag
>> <%@taglib prefix="s" uri="/struts-tags" %> <s:date 
>> name="person.birthday" format="dd/MM/yyyy" /> if no format is 
>> specified format defaults to DateFormat.MEDIUM (in US = MMM 
>> d, yyyy)http://struts.apache.org/2.0.14/docs/date.html
>>
>> HTH
>> Martin
>> ______________________________________________
>> Disclaimer and Confidentiality/Verzicht und 
>> Vertraulichkeitanmerkung/Note de déni et de confidentialité 
>> This message is confidential. If you should not be the 
>> intended receiver, then we ask politely to report. Each 
>> unauthorized forwarding or manufacturing of a copy is 
>> inadmissible. This message serves only for the exchange of 
>> information and has no legal binding effect. Due to the easy 
>> manipulation of emails we cannot take responsibility over the 
>> the contents.
>> Diese Nachricht ist vertraulich. Sollten Sie nicht der 
>> vorgesehene Empfaenger sein, so bitten wir hoeflich um eine 
>> Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer 
>> Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
>> Austausch von Informationen und entfaltet keine rechtliche 
>> Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von 
>> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>> Ce message est confidentiel et peut être privilégié. Si vous 
>> n'êtes pas le destinataire prévu, nous te demandons avec 
>> bonté que pour satisfaire informez l'expéditeur. N'importe 
>> quelle diffusion non autorisée ou la copie de ceci est 
>> interdite. Ce message sert à l'information seulement et 
>> n'aura pas n'importe quel effet légalement obligatoire. Étant 
>> donné que les email peuvent facilement être sujets à la 
>> manipulation, nous ne pouvons accepter aucune responsabilité 
>> pour le contenu fourni.
>>
>>
>>
>>
>>> Date: Wed, 6 May 2009 14:04:33 -0400
>>> From: Terry.Gardner@Sun.COM
>>> Subject: Re: Date/time formatting
>>> To: user@struts.apache.org
>>>
>>> java.text.SimpleDateFormat formats a java.util.Date according to a 
>>> locale and a patter specified by the client.
>>>
>>> On May 6, 2009, at 1:10 PM, Jon Pearson wrote:
>>>
>>>> If I wanted to output a date/time value in the user's locale, is 
>>>> there a simple way to do that? I see there is a <date> tag which 
>>>> would be helpful for getting the date format correct without 
>>>> manually specifying it, but what about a similar <time> tag? Am I 
>>>> going to need to manually specify the standard date 
>> format as "M/D/y 
>>>> h/mm/ss a" for US English, and just require any translation to 
>>>> specify its own?
>>>>
>>>> Thanks,
>>>> ~Jonathan
>>>>
>>>>
>> --------------------------------------------------------------------
>>>> - To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>> _________________________________________________________________
>> Hotmail® has ever-growing storage! Don't worry about storage limits.
>> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM
>> _WL_HM_Tutorial_Storage1_052009
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

-- 
René Gielen
IT-Neering.net
Saarstrasse 100, 52062 Aachen, Germany
Tel: +49-(0)241-4010770
Fax: +49-(0)241-4010771
http://twitter.com/rgielen

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


RE: Date/time formatting

Posted by Jon Pearson <Jo...@sixnet.com>.
Right, but I don't want to specify the format explicitely, since it should depend on the localization of the browser. But when I don't specify it, I don't get the time included in the output. Is there a way to get both?
 

> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@hotmail.com] 
> Sent: Wednesday, May 06, 2009 2:20 PM
> To: Struts Users Mailing List
> Subject: RE: Date/time formatting
> 
> 
> you can also use the Struts date tag
> <%@taglib prefix="s" uri="/struts-tags" %> <s:date 
> name="person.birthday" format="dd/MM/yyyy" /> if no format is 
> specified format defaults to DateFormat.MEDIUM (in US = MMM 
> d, yyyy)http://struts.apache.org/2.0.14/docs/date.html
> 
> HTH
> Martin
> ______________________________________________
> Disclaimer and Confidentiality/Verzicht und 
> Vertraulichkeitanmerkung/Note de déni et de confidentialité 
> This message is confidential. If you should not be the 
> intended receiver, then we ask politely to report. Each 
> unauthorized forwarding or manufacturing of a copy is 
> inadmissible. This message serves only for the exchange of 
> information and has no legal binding effect. Due to the easy 
> manipulation of emails we cannot take responsibility over the 
> the contents.
> Diese Nachricht ist vertraulich. Sollten Sie nicht der 
> vorgesehene Empfaenger sein, so bitten wir hoeflich um eine 
> Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer 
> Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
> Austausch von Informationen und entfaltet keine rechtliche 
> Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von 
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous 
> n'êtes pas le destinataire prévu, nous te demandons avec 
> bonté que pour satisfaire informez l'expéditeur. N'importe 
> quelle diffusion non autorisée ou la copie de ceci est 
> interdite. Ce message sert à l'information seulement et 
> n'aura pas n'importe quel effet légalement obligatoire. Étant 
> donné que les email peuvent facilement être sujets à la 
> manipulation, nous ne pouvons accepter aucune responsabilité 
> pour le contenu fourni.
> 
> 
> 
> 
> > Date: Wed, 6 May 2009 14:04:33 -0400
> > From: Terry.Gardner@Sun.COM
> > Subject: Re: Date/time formatting
> > To: user@struts.apache.org
> > 
> > java.text.SimpleDateFormat formats a java.util.Date according to a 
> > locale and a patter specified by the client.
> > 
> > On May 6, 2009, at 1:10 PM, Jon Pearson wrote:
> > 
> > > If I wanted to output a date/time value in the user's locale, is 
> > > there a simple way to do that? I see there is a <date> tag which 
> > > would be helpful for getting the date format correct without 
> > > manually specifying it, but what about a similar <time> tag? Am I 
> > > going to need to manually specify the standard date 
> format as "M/D/y 
> > > h/mm/ss a" for US English, and just require any translation to 
> > > specify its own?
> > >
> > > Thanks,
> > > ~Jonathan
> > >
> > > 
> --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > 
> 
> _________________________________________________________________
> Hotmail® has ever-growing storage! Don't worry about storage limits.
> http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM
> _WL_HM_Tutorial_Storage1_052009
> 

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


RE: Date/time formatting

Posted by Martin Gainty <mg...@hotmail.com>.
you can also use the Struts date tag
<%@taglib prefix="s" uri="/struts-tags" %>
<s:date name="person.birthday" format="dd/MM/yyyy" />
if no format is specified format defaults to DateFormat.MEDIUM
(in US = MMM d, yyyy)http://struts.apache.org/2.0.14/docs/date.html

HTH
Martin 
______________________________________________ 
Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents.
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 6 May 2009 14:04:33 -0400
> From: Terry.Gardner@Sun.COM
> Subject: Re: Date/time formatting
> To: user@struts.apache.org
> 
> java.text.SimpleDateFormat formats a java.util.Date according to a  
> locale and a patter specified by the client.
> 
> On May 6, 2009, at 1:10 PM, Jon Pearson wrote:
> 
> > If I wanted to output a date/time value in the user's locale, is  
> > there a
> > simple way to do that? I see there is a <date> tag which would be
> > helpful for getting the date format correct without manually  
> > specifying
> > it, but what about a similar <time> tag? Am I going to need to  
> > manually
> > specify the standard date format as "M/D/y h/mm/ss a" for US English,
> > and just require any translation to specify its own?
> >
> > Thanks,
> > ~Jonathan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> 

_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage1_052009

Re: Date/time formatting

Posted by Terry Gardner <Te...@Sun.COM>.
java.text.SimpleDateFormat formats a java.util.Date according to a  
locale and a patter specified by the client.

On May 6, 2009, at 1:10 PM, Jon Pearson wrote:

> If I wanted to output a date/time value in the user's locale, is  
> there a
> simple way to do that? I see there is a <date> tag which would be
> helpful for getting the date format correct without manually  
> specifying
> it, but what about a similar <time> tag? Am I going to need to  
> manually
> specify the standard date format as "M/D/y h/mm/ss a" for US English,
> and just require any translation to specify its own?
>
> Thanks,
> ~Jonathan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>