aspose file tools*
The moose likes JDBC and the fly likes Date Insert Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Date Insert" Watch "Date Insert" New topic
Author

Date Insert

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi all,
i want to know how i can convert a string into a date data type.
String date=request.getParameter("txtGraduationdate");
well in my backend i created the field as "date" data type.
So how will i be able to convert this.
Thanks and Regards,
vikram
Toyin Sogeke
Greenhorn

Joined: Oct 08, 2001
Posts: 14
Hello Sir,
You can use java class java.text.SimpleDateFormat
for your conversion as follows:
String stringDate = "2001-10-08";
SimpleDateFormat sdfInput =
new SimpleDateFormat( "yyyy-MM-dd" );
java.util.Date date = sdfInput.parse( stringDate );
Cheers
Originally posted by vikramnp:
Hi all,
i want to know how i can convert a string into a date data type.
String date=request.getParameter("txtGraduationdate");
well in my backend i created the field as "date" data type.
So how will i be able to convert this.
Thanks and Regards,
vikram


homeboy
Dharmesh Chheda
Ranch Hand

Joined: May 08, 2001
Posts: 204
Hello vikramp
the second way is that you can use the StringTokenizer class also
------------------
IBM Certified WebSphere Application Server V3.5 Specialist


regards,<br />Dharmesh Chheda
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

This is the way I convert it. I wish there was an easier way too!

Calendar.getTime() returns a Date object, then use getTime() on the Date object which returns milliseconds, which you can use in a Date constructor to create a new Date.
Jamie


[This message has been edited by Jamie Robertson (edited October 15, 2001).]
[This message has been edited by Jamie Robertson (edited October 15, 2001).]
 
Don't get me started about those stupid light bulbs.
 
subject: Date Insert