*
The moose likes Beginning Java and the fly likes Help:java.lang.String and java.sql.Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help:java.lang.String and java.sql.Date" Watch "Help:java.lang.String and java.sql.Date" New topic
Author

Help:java.lang.String and java.sql.Date

Sura Lin
Greenhorn

Joined: Feb 22, 2002
Posts: 6
I have a problem.
If there is a java.lang.String,how can i turn it to java.sql.Date?
for example:
String temp="2001/12/12";
java.sql.Date date=???

plz,plz,help me
thanks


bull
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi,
You can use
Date.toString(String)
which returns a sql date.
Raj
gautam shah
Ranch Hand

Joined: Oct 29, 2000
Posts: 72
public static Date valueOf(String s)
Converts a string in JDBC date escape format to a Date value.
Parameters:
s - date in format "yyyy-mm-dd"
Returns:
a Date object representing the given date
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Sorry for my previous reply. i was about to write the method
Date.valueOf(String) which returns a Date but instead, i wrote as
Date.toString(String) which returns a String..
sorry folks...
Raj
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
Rajendar G,
Please read theJavaranch naming policy and change your display name to one that conforms if you wish to continue posting here. Thanks.


Matthew Phillips
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Moving this from Servlets -> Java In General (Beginner)
 
 
subject: Help:java.lang.String and java.sql.Date