• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic