• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't convert String to Date...

 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,
I defined these two variables as a date
Date dateWork
Date ConvertedDate
and I don't know why it gives me this error message? and doesn't accept it. how can I solve it?
ConvertedDate = formatter.format(dateWork);
Thanks,
Elahe
Error
------
Incompatible type for =. Can't convert String to Date.
ConvertedDate = formatter.format(dateWork);
^
1 error
 
Col Bell
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you take a look at the JavaDoc for the format() function you'll see it is defined like:

That is it returns a String object, not a Date. The purpose of the function is to give you the passed Date object in a human-readable form.
[ April 13, 2002: Message edited by: Col Bell ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic