• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Sura Lin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rajendar Goud
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use
Date.toString(String)
which returns a sql date.
Raj
 
gautam shah
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 220
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajendar G,
Please read theJavaranch naming policy and change your display name to one that conforms if you wish to continue posting here. Thanks.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this from Servlets -> Java In General (Beginner)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic