-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Neil,

Neil Meyer wrote:
> Code used.
> 
> String date_ = "2007-03-07 00:00:00"
> SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
> return formatter.format(date_); 

SimpleDateFormat.format() is expecting a java.util.Date argument, not a
String. If you want to convert a String to a Date, you need to use
SimpleDateFormat.parse(), which accepts a String argument and returns a
java.util.Date object.

> 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);

dateString doesn't match your format. According to the Javadoc,
java.util.Date.toString dumps a string in the format "dow mon dd
hh:mm:ss zzz yyyy", which, unfortunately for you, uses localized names
for the day of the week and the month. If you want to parse strings
coming from Date.toString, you'll need to adjust your format when you
create SimpleDateFormat to match what you're trying to parse.

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

Another poster suggested using <bean:write> with the "format" argument,
which can be used to format java.util.Date objects in whatever way you
choose.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF7vU59CaO5/Lv0PARAlnRAJ9lQajsAi/4N+9//U+S+Fe+zq5KBQCcDQR/
5e2IaMgf1CCjWbtIcAskVBU=
=qzCU
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to