Hello Andrew,

how is weather in SA? Here in Germany it is snowing!

Please see my answer below:

But the people using the app that I am writing don't want type 01/30/2003 to get the reports.
The main reason is that the company that I am working for is in Germany. So the user wants to put 30.01.2003 in the form.
If I parse that into the esql I can't get any data out of db.

So to avoid worring about the format the user uses,
I could use a JavaScript with my html-Form:
1) <input type="text" name="date">31.01.2003</input>
2) transform that date before submit -> result: 01/31/2003
3) request it with ?date=01/31/2003
4) ...and had no problems.
I'm not sure if you've understood the <esql:parameter> concept fully.
Using the esql parameter will result in java code that looks something
like the following:
...
When using code like this, you don't have to worry about the format the
database engine uses, you only have to worry about the format the user
uses and parse that into a Date object.
You are right! I think that is the actual problem.

The parsed date in the request (?date=01/31/03) is a string!

That was the conclusion the let me to the following code (date.xsp). I assume the request is ?date=30.01.2002 (datePattern = "dd.MM.yyyy").

<xsp:page language="java" xmlns:xsp="http://apache.org/xsp";>
<xsp:structure>
<xsp:include>java.util.*</xsp:include>
<xsp:include>java.text.*</xsp:include>
</xsp:structure>
<document>
<xsp:logic>
String datePattern = "dd.MM.yyyy";
SimpleDateFormat dateFormat = new SimpleDateFormat( datePattern );
String sDate_one = "31.01.2002";
String sDate_two = request.getParameter("date");
Date date_one = null;
try
{
date_one = dateFormat.parse( sDate_two );
}
catch( ParseException e )
{
getLogger().error("XSP date error: ", e);
}
</xsp:logic>
<request>
<xsp:expr>sDate_two</xsp:expr>
</request>
<transformed>
<xsp:expr>date_one</xsp:expr>
</transformed>
<static>
<xsp:expr>sDate_one</xsp:expr>
</static>
</document>
</xsp:page>

Thanks again for all the help and your time!

King regards
Thorsten
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp";>
        <xsp:structure>
                <xsp:include>java.util.*</xsp:include>
                <xsp:include>java.text.*</xsp:include>
        </xsp:structure>
        <document>
                <xsp:logic>
         String datePattern = "dd.MM.yyyy";
       SimpleDateFormat dateFormat = new SimpleDateFormat( datePattern );
       
       String sDate_one = "31.01.2002";
       String sDate_two = request.getParameter("date");
       
       Date date_one = null;
        try
       {
           date_one = dateFormat.parse( sDate_two );
       }
       catch( ParseException e )
       {
 getLogger().error("XSP date error: ", e);
}       
</xsp:logic>
                <request>
                        <xsp:expr>sDate_two</xsp:expr>
                </request>
                <transformed>
                        <xsp:expr>date_one</xsp:expr>
                </transformed>
                <static>
                        <xsp:expr>sDate_one</xsp:expr>
                </static>
        </document>
</xsp:page>

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

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

Reply via email to