aspose file tools
The moose likes JDBC and the fly likes Can't convert String to Date... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "Can Watch "Can New topic
Author

Can't convert String to Date...

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
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


Thanks,
Elahe
Col Bell
Greenhorn

Joined: Mar 21, 2002
Posts: 12
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 ]

Col<br /><a href="http://www.squirrelsql.org" target="_blank" rel="nofollow">http://www.squirrelsql.org</a>
 
IntelliJ Java IDE
 
subject: Can't convert String to Date...
 
Threads others viewed
Calendar Object to String
Converting string to specific date format
Convert String to Date format
How to write to new table?
How can I solve IllegalArgumentException
IntelliJ Java IDE