Mark,
It sounds like you have a List of "Individual" objects, and the velocity
template is doing something like
#foreach (ind in $individualList)
$ind.dateColumn
#end
Velocity is effectively calling individual.getDateColumn().toString(), so
you will get whatever default date conversion the java.sql.Date object
provides (or java.sql.Timestamp, depending on what type your date column
is).
You can always pass a java.text.SimpleDateFormat object into your Context
for use in the template, also. Maybe Context.put("df", new
SimpleDateFormat...) and $df.format($ind.dateColumn) will work--I don't know
if Velocity coerces objects to strings via toString as soon as they're
obtained, or not until they're displayed for output.
-- Bill
----- Original Message -----
From: "Mark Kaye" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 25, 2002 6:00 AM
Subject: Date formats
> Quick question! I hope :) What's the best way to change a date format
> before I add it to my velocity context?
>
> I have the following code:
>
> Criteria crit = new Criteria();
> List individualList = IndividualPeer.doSelect(crit);
> Context.put("individuallist", individualList);
>
> One of the columns returned from the select is a date column. Currently
> it is returned as e.g. 1974-08-22 00:00:00.0 but all I need is the
> 1974-08-22 portion of that. Can I change the date format as part of the
> criteria or am I better off modifying the List object after the select
> has populated it?
>
> Best regards,
>
> Mark
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>