You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Hunter, Sandra" <Sa...@BCTransit.Com> on 2003/05/26 15:14:36 UTC

OT? JSP problem with Dates

I am receiving a date from an Oracle database and I need to display and
handle it in this format: dd-mon-yy
However it is coming from Oracle in this format: 12/25/2085 0:0:0
This is what I am trying to do to convert it to the correct format:
String start = null;
String tempStart 	= null;
tempStart = cardSet.getString("dat_exp");
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat
("dd/mm/yy mm:ss:SS"); 
java.util.Date tempStartDate = formatter.parse(tempStart, new
java.text.ParsePosition(0)); 
formatter.applyPattern("dd-MMM-yy");
start = formatter.format(tempStart);

This compiles but Tomcat is displaying this error and the app grinds to a
halt:
Cannot format given Object as a Date

Does anybody have a better way of doing this that will not kick up a fuss?

Thanks
Sandra

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: OT? JSP problem with Dates

Posted by Daniel Montero <da...@soin.co.cr>.
Perhaps you can use uppercase "MM" for the month ?

like in:

java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat
("dd/MM/yy mm:ss:SS");

----- Original Message ----- 
From: "Hunter, Sandra" <Sa...@BCTransit.Com>
To: "'Tomcat Users List'" <to...@jakarta.apache.org>
Sent: Monday, May 26, 2003 7:14 AM
Subject: OT? JSP problem with Dates


> I am receiving a date from an Oracle database and I need to display and
> handle it in this format: dd-mon-yy
> However it is coming from Oracle in this format: 12/25/2085 0:0:0
> This is what I am trying to do to convert it to the correct format:
> String start = null;
> String tempStart = null;
> tempStart = cardSet.getString("dat_exp");
> java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat
> ("dd/mm/yy mm:ss:SS");
> java.util.Date tempStartDate = formatter.parse(tempStart, new
> java.text.ParsePosition(0));
> formatter.applyPattern("dd-MMM-yy");
> start = formatter.format(tempStart);
>
> This compiles but Tomcat is displaying this error and the app grinds to a
> halt:
> Cannot format given Object as a Date
>
> Does anybody have a better way of doing this that will not kick up a fuss?
>
> Thanks
> Sandra
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org