You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Raj Yadav <ra...@otavi.com> on 2003/12/20 00:41:35 UTC
[OT] Date Problem
Hi All,
I have date stored in a flat log file like this:
Mon Dec 15 00:00:52 2003
I read the log file and get this date as a String.
I want to insert this date into a Oracle table.
My method is like this:
public static java.sql.Date StringToDate(String date)
{
java.sql.Date retDate = null;
try
{
String incomingDate = date;
SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM d
HH:mm:ss
yyyy");
java.util.Date d = formatter.parse(incomingDate);
retDate = new java.sql.Date(d.getTime());
System.out.println("retDate = " + retDate);
//retDate = (java.sql.Date)formatter.parse(incomingDate);
}
catch(ParseException prsEx)
{
System.out.println("Parsing Exception in Utils = " + prsEx);
}
return retDate;
}
It is inserting only MM/dd/YYYY and not the time.
How do i insert the whole date with the time
thanks,
-raj
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org