Imelda
asked on
Date
I read from plain text and i got "Tue Nov 23 15:11:44 1999" string. How could i store it in my database that has table with a Date/Time field ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy");
ParsePosition pos = new ParsePosition(0);
java.util.Date dte = sdf.parse("Tue Nov 23 15:11:44 1999", pos);
can be used for parsing the date from String object to Date object.
js.
ParsePosition pos = new ParsePosition(0);
java.util.Date dte = sdf.parse("Tue Nov 23 15:11:44 1999", pos);
can be used for parsing the date from String object to Date object.
js.
You don't need to. You just pass the Date() object.
ASKER
I must use java.util.Date or java.sql.Date ? Beside that, how to change "Tue Nov 23 15:11:44 1999" into format "yyyy-mm-dd" ?
My friend tell me I can pass string into date field in the table. It will convert automatically. Is that true ?
My friend tell me I can pass string into date field in the table. It will convert automatically. Is that true ?
This is answered in your query on "Date II"
js.
js.
Before setting date in preparedStatement , it should be in yyyy-mm-dd format.
How will you convert
Tue Nov 23 15:11:44 1999
to
1999-11-23
Thank you