• Post Reply Bookmark Topic Watch Topic
  • New Topic

converting a string into a date  RSS feed

 
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am passing date as a string through a HTML form. I want to insert this string into a DATE.
I am using the following code
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try
{
d = df.parse(weekEnding);
}
catch(ParseException e)
{
}
where weekending is a string "2004-02-02"
But I get the follwoing code:

found : java.util.Date
required: java.sql.Date
d = df.parse(weekEnding);
But I thought SimpleDateFormat passes a Java.util.Date.
Thansk for any help
Tony
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your import statement.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!