Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Struts 2 »

Re: Struts Date Formatting

nuwan chandrasoma

2007-03-07

Replies:

hi,

you can use, <bean:write> with the format attribute.

eg:-

<bean:write name="order" property="createdDate" format="dd/MM/yyyy"/>

Regards,

Nuwan

----- Original Message -----
From: "Neil Meyer" <neil.meyer@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Wednesday, March 07, 2007 4:19 PM
Subject: Struts Date Formatting


Hallo,

I would like to find a struts tag that can do date formatting for me?

I tried to do it within my objects but it keeps on giving me exceptions

Code used.


String date_ = "2007-03-07 00:00:00"
SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
return formatter.format(date_);

FAILED

Date now = new Date();

    // Print the result of toString()
String dateString = now.toString();
    System.out.println(" 1. " + dateString);

SimpleDateFormat format = new SimpleDateFormat("dd MMM yyyy");

    try {
       Date parsed = format.parse(dateString);

}catch(Exception e){}

FAILED

Any help either the struts formatting or the way to fix it will really be
appreciated.

Kr
Neil Meyer

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.