On Tue, 2010-07-27 at 21:45 +0200, Michal Ciasnocha wrote:

> Why don't use Struts tag s:date for date formatting?
> 
> in Action:
> 
> public GregorianCalendar getMyDate() {
>        return new GregorianCalendar();
> }
> 
> in jsp:
> 
> <s:date name="myDate" format="d. M. yyyy HH:mm" />
> 
> Michal
> 
> > Hi all,
> > i do it like that:
> > in my POJO GregorianCalendar field,
> > on my jsp text field + jquery calendar.
> > If You want to create date in some kind of predefined format
> > You can use Conventer for GregorianCalendar for your app.

Ah, too easy... I had been using DateTimePicker and confused the two.

Well in my efforts to output the GregorianCalendar object in OGNL I had
troubles,
although it is clearly not the best way (clearly to me now that is)...
Perhaps 
someone can explain:
1) Casting in OGNL, and 2) Referencing static field definitions in
OGNL...

For instance in my efforts to get the date out I wrote:
<s:property value=" '' + courseStartDate.get(1) + '-' +
{courseStartDate.get(2) + 1} + '-' + courseStartDate.get(5)"/>

Where: 
courseStartDate.get(1) aught to be written
courseStartDate.get(Calendar.YEAR),
courseStartDate.get(2) aught to be written courseStartDate.get(MONTH)
courseStartDate.get(5) aught to be written
courseStartDate.get(Calendar.DATE),
maybe it works it just didn't seem to for me...

Then I had difficulties because of automatic type conversion...
The Month is 0 based so I need to add 1 to the date, so I tried...
(courseStartDate.get(2) + 1) but I think that resulted in the string "1"
being appended to the end of everything...
the closest I could get was {courseStartDate.get(2) + 1} and that prints
the correct number but inside square brackets.

So after all that Michal pointed out the obvious and I threw all this
out the window and just used the date tag but I'd still like to address
these issues.



Reply via email to