cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Kovacs" <al...@fast.fujitsu.com.au>
Subject Re: Problem with date format for a woody widget in xsp
Date Wed, 11 Feb 2004 04:16:54 GMT
Hi Tony,

Thanks for the help, I will try it and let you know how it worked.

Rgds,
Alex

----- Original Message ----- 
From: "Tony Edwards" <tedwards@civica.com.au>
To: <users@cocoon.apache.org>
Sent: Wednesday, February 11, 2004 9:42 AM
Subject: Re: Problem with date format for a woody widget in xsp


> Hi Alex,
> I had a similar problem saving data back to a MySql database. The 
> database only recognises dates in yyyy-MM-dd format and the flowscript 
> was outputting dates like so:
> EEE, d MMM yyyy HH:mm:ss Z (the same as your issue).
> I fiddled with the <wd:convertor> settings but it didn't change the 
> resulting format being sent to the database.
> To solve the problem I downloaded a date formatting javascript library 
> from Matt Kruse (WWW: http://www.mattkruse.com/) called date.js (funny 
> that).
> It was then just a simple call to a formatting method and the record was 
> written without complaint.
> Another more xsp-centric solution is to include the following code in 
> your xsp page:
> <xsp:page> 
>  <xsp:structure>
>         <xsp:include>java.util.Date</xsp:include>
>         <xsp:include>java.util.Calendar</xsp:include>
>         <xsp:include>java.lang.Integer</xsp:include>
>         <xsp:include>java.util.GregorianCalendar</xsp:include>
>         <xsp:include>java.text.SimpleDateFormat</xsp:include>
>         <xsp:include>java.lang.String</xsp:include>
>     </xsp:structure>
> 
>     <xsp:logic>
>         <![CDATA[
>             public static String formatDate(Date value, String format) {
>                 SimpleDateFormat formatter;
>                 format = format.trim();
>                 if (format != null && !"".equals(format)) {
>                     formatter = new SimpleDateFormat(format);
>                 }
>                 else {
>                     formatter = new SimpleDateFormat();
>                 }
>                
>                 return formatter.format(value);
>             }
>     </xsp:logic>
> <content>             
>                 <para>Select 'Add' or 'View' from the options then 
> select the month and year for the notice:</para>
>                 <para>Today's date is <xsp:expr>formatDate(new Date(), 
> "dd-MMM-yyyy")</xsp:expr></para><br/>
>  </content> 
> </xsp:page>          
> Hope this helps,
> Regards,
> Tony
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message