You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marc BEGUIGNEAU <ma...@yahoo.fr> on 2003/06/27 09:15:12 UTC

How I can format a date to display

Hello,

With Struts, I'm using Torque to access a database
under Oracle 9.

The result of a search in an array of bean (values
object bean).

This bean as an property witch is a date. When I
iterate this array in my JSP page, the date are
displaying under US format (year/month/day). To format
the display to french format (day/month/year), I
convert the date to a string with the
SimpleDateFormat, and then I parse the result string
into a date and try to display it. But the result is a
date with the FULL format.

This is an extract of the code I use to convert:

<code>

SimpleDateFormat dateFormat = new
SimpleDateFormat("dd/MM/yyyy");

String tempDate =
dateFormat.format("offer.getOfferDate");

try {

offerVO.setOfferDate(dateFormat.parse(tempDate));

} catch (ParseException e) {
System.out.println()e.toString();
}

</code>

My question is: how do you display date if you want to
have a specific formating display?

Curently, I have solv the problem by using a String
property in my VO bean, but this solution is
temporary.

Thank you in advance.

Marc

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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


Re: How I can format a date to display

Posted by Kris Schneider <kr...@dotech.com>.
If you can use JSTL:

<c:forEach var="offerVO" items="${offers}">
  ...
  <fmt:formatDate value="${offerVO.offerDate}" pattern="dd/MM/yyyy"/>
  ...
</c:forEach>

Quoting Sandeep Takhar <sa...@yahoo.com>:

> there are c:fmt tags in el.  I haven't used them
> though...
> 
> sandeep
> --- ara <ht...@yahoo.co.jp> wrote:
> > Hi,Marc.
> > 
> > i use my custom tag.
> > 
> > <!-- **** DateTag Definition **** -->
> >   <tag>
> >     <name>date</name>
> >    
> > <tagclass>xx.yy.zz.view.taglibs.DateTag</tagclass>
> >     <bodycontent>empty</bodycontent>
> >     <info>format Data</info>
> >     <attribute>
> >       <name>sourceDate</name>
> >       <required>false</required>
> >       <rtexprvalue>true</rtexprvalue>
> >     </attribute>
> >     <attribute>
> >       <name>pattern</name>
> >       <required>false</required>
> >       <rtexprvalue>true</rtexprvalue>
> >     </attribute>
> >     <attribute>
> >       <name>name</name>
> >       <required>false</required>
> >       <rtexprvalue>true</rtexprvalue>
> >     </attribute>
> >     <attribute>
> >       <name>property</name>
> >       <required>false</required>
> >       <rtexprvalue>true</rtexprvalue>
> >     </attribute>
> >     <attribute>
> >       <name>scope</name>
> >       <required>false</required>
> >       <rtexprvalue>true</rtexprvalue>
> >     </attribute>
> >   </tag>
> > 
> > 
> > ----- Original Message ----- 
> > From: "Marc BEGUIGNEAU" <ma...@yahoo.fr>
> > To: <st...@jakarta.apache.org>
> > Sent: Friday, June 27, 2003 4:15 PM
> > Subject: How I can format a date to display
> > 
> > 
> > > Hello,
> > > 
> > > With Struts, I'm using Torque to access a database
> > > under Oracle 9.
> > > 
> > > The result of a search in an array of bean (values
> > > object bean).
> > > 
> > > This bean as an property witch is a date. When I
> > > iterate this array in my JSP page, the date are
> > > displaying under US format (year/month/day). To
> > format
> > > the display to french format (day/month/year), I
> > > convert the date to a string with the
> > > SimpleDateFormat, and then I parse the result
> > string
> > > into a date and try to display it. But the result
> > is a
> > > date with the FULL format.
> > > 
> > > This is an extract of the code I use to convert:
> > > 
> > > <code>
> > > 
> > > SimpleDateFormat dateFormat = new
> > > SimpleDateFormat("dd/MM/yyyy");
> > > 
> > > String tempDate =
> > > dateFormat.format("offer.getOfferDate");
> > > 
> > > try {
> > > 
> > > offerVO.setOfferDate(dateFormat.parse(tempDate));
> > > 
> > > } catch (ParseException e) {
> > > System.out.println()e.toString();
> > > }
> > > 
> > > </code>
> > > 
> > > My question is: how do you display date if you
> > want to
> > > have a specific formating display?
> > > 
> > > Curently, I have solv the problem by using a
> > String
> > > property in my VO bean, but this solution is
> > > temporary.
> > > 
> > > Thank you in advance.
> > > 
> > > Marc

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Re: How I can format a date to display

Posted by Sandeep Takhar <sa...@yahoo.com>.
there are c:fmt tags in el.  I haven't used them
though...

sandeep
--- ara <ht...@yahoo.co.jp> wrote:
> Hi,Marc.
> 
> i use my custom tag.
> 
> <!-- **** DateTag Definition **** -->
>   <tag>
>     <name>date</name>
>    
> <tagclass>xx.yy.zz.view.taglibs.DateTag</tagclass>
>     <bodycontent>empty</bodycontent>
>     <info>format Data</info>
>     <attribute>
>       <name>sourceDate</name>
>       <required>false</required>
>       <rtexprvalue>true</rtexprvalue>
>     </attribute>
>     <attribute>
>       <name>pattern</name>
>       <required>false</required>
>       <rtexprvalue>true</rtexprvalue>
>     </attribute>
>     <attribute>
>       <name>name</name>
>       <required>false</required>
>       <rtexprvalue>true</rtexprvalue>
>     </attribute>
>     <attribute>
>       <name>property</name>
>       <required>false</required>
>       <rtexprvalue>true</rtexprvalue>
>     </attribute>
>     <attribute>
>       <name>scope</name>
>       <required>false</required>
>       <rtexprvalue>true</rtexprvalue>
>     </attribute>
>   </tag>
> 
> 
> ----- Original Message ----- 
> From: "Marc BEGUIGNEAU" <ma...@yahoo.fr>
> To: <st...@jakarta.apache.org>
> Sent: Friday, June 27, 2003 4:15 PM
> Subject: How I can format a date to display
> 
> 
> > Hello,
> > 
> > With Struts, I'm using Torque to access a database
> > under Oracle 9.
> > 
> > The result of a search in an array of bean (values
> > object bean).
> > 
> > This bean as an property witch is a date. When I
> > iterate this array in my JSP page, the date are
> > displaying under US format (year/month/day). To
> format
> > the display to french format (day/month/year), I
> > convert the date to a string with the
> > SimpleDateFormat, and then I parse the result
> string
> > into a date and try to display it. But the result
> is a
> > date with the FULL format.
> > 
> > This is an extract of the code I use to convert:
> > 
> > <code>
> > 
> > SimpleDateFormat dateFormat = new
> > SimpleDateFormat("dd/MM/yyyy");
> > 
> > String tempDate =
> > dateFormat.format("offer.getOfferDate");
> > 
> > try {
> > 
> > offerVO.setOfferDate(dateFormat.parse(tempDate));
> > 
> > } catch (ParseException e) {
> > System.out.println()e.toString();
> > }
> > 
> > </code>
> > 
> > My question is: how do you display date if you
> want to
> > have a specific formating display?
> > 
> > Curently, I have solv the problem by using a
> String
> > property in my VO bean, but this solution is
> > temporary.
> > 
> > Thank you in advance.
> > 
> > Marc
> > 
> >
>
___________________________________________________________
> > Do You Yahoo!? -- Une adresse @yahoo.fr gratuite
> et en
> fran
> ais !
> > Yahoo! Mail : http://fr.mail.yahoo.com
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! BB is Broadband by Yahoo! 
> http://bb.yahoo.co.jp/
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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


Re: How I can format a date to display

Posted by ara <ht...@yahoo.co.jp>.
Hi,Marc.

i use my custom tag.

<!-- **** DateTag Definition **** -->
  <tag>
    <name>date</name>
    <tagclass>xx.yy.zz.view.taglibs.DateTag</tagclass>
    <bodycontent>empty</bodycontent>
    <info>format Data</info>
    <attribute>
      <name>sourceDate</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
      <name>pattern</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
      <name>name</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
      <name>property</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
      <name>scope</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>


----- Original Message ----- 
From: "Marc BEGUIGNEAU" <ma...@yahoo.fr>
To: <st...@jakarta.apache.org>
Sent: Friday, June 27, 2003 4:15 PM
Subject: How I can format a date to display


> Hello,
> 
> With Struts, I'm using Torque to access a database
> under Oracle 9.
> 
> The result of a search in an array of bean (values
> object bean).
> 
> This bean as an property witch is a date. When I
> iterate this array in my JSP page, the date are
> displaying under US format (year/month/day). To format
> the display to french format (day/month/year), I
> convert the date to a string with the
> SimpleDateFormat, and then I parse the result string
> into a date and try to display it. But the result is a
> date with the FULL format.
> 
> This is an extract of the code I use to convert:
> 
> <code>
> 
> SimpleDateFormat dateFormat = new
> SimpleDateFormat("dd/MM/yyyy");
> 
> String tempDate =
> dateFormat.format("offer.getOfferDate");
> 
> try {
> 
> offerVO.setOfferDate(dateFormat.parse(tempDate));
> 
> } catch (ParseException e) {
> System.out.println()e.toString();
> }
> 
> </code>
> 
> My question is: how do you display date if you want to
> have a specific formating display?
> 
> Curently, I have solv the problem by using a String
> property in my VO bean, but this solution is
> temporary.
> 
> Thank you in advance.
> 
> Marc
> 
>
___________________________________________________________
> Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en
fran
ais !
> Yahoo! Mail : http://fr.mail.yahoo.com
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
struts-user-help@jakarta.apache.org
> 


__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!  http://bb.yahoo.co.jp/


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