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


Alex Kovacs wrote:

Hi,

I am using cocoon-2.1.3 with Woody. I have a situation where I am using
xsp
to display some data from a Woody form. The problem is when trying to
display the value of a date widget and the date format is the default
one
instead of the one set in the widget definition. I have the following
configuration (using xml binding):

Widget definition:
       ...
       <wd:field id="start_date">
           <wd:datatype base="date">
               <wd:convertor type="formatting">
                   <wd:patterns>
                       <wd:pattern>dd/MM/yyyy</wd:pattern>
                   </wd:patterns>
               </wd:convertor>
           </wd:datatype>
           <wd:label>Start Date</wd:label>
       </wd:field>
       ...


The confirm.xsp file: ... <xsp:logic> //Fetching the form from the request attribute Form form = (Form)request.getAttribute("theform"); Field start_date = (Field)form.getWidget("start_date"); </xsp:logic> ... <item> <xsp:expr>start_date.getValue()</xsp:expr> </item> ...

And the output is in the form of: "Tue Feb 10 00:00:00 EST 2004",
instead of
"10/02/2004".

Can anyone help?
Rgds
Alex



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





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



Reply via email to