• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Can't convert String to Date...

 
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
What are you doing? You are supposed to be reading this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic