my dog learned polymorphism
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
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

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

Sura Lin

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

Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
You can use
which returns a sql date.
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.
s - date in format "yyyy-mm-dd"
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...
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)
I agree. Here's the link:
subject: Help:java.lang.String and java.sql.Date
It's not a secret anymore!