| Author |
Convert String to Date
|
Death Arte
Greenhorn
Joined: Feb 17, 2011
Posts: 21
|
|
Good day!
Im new here and i would like to ask a little help from you guys.
How to convert String to Date?
Code:
Eclipse display this error message:
Type mismatch: cannot convert from String to Date
i've read that everything found in google search but it still error.
PS: sorry for my Grammar.. Thank you and God bless you all!
|
 |
sri ramvaithiyanathan
Ranch Hand
Joined: Nov 20, 2010
Posts: 109
|
|
Hi,
Welcome to Ranch world.
check this Link and this Link
Regards,
Sriram.V
|
For java examples,ebooks,interview questions,visit this blog
http://periodicupdates.blogspot.com/
|
 |
Joe carco
Ranch Hand
Joined: Apr 14, 2009
Posts: 82
|
|
Looks like your in the wrong Forum. Your question has nothing to do with Servlets.
Seems like youre confusing parsing and formatting. To format a date you need a Date and not a String. If you want to create a Date from a String try this:
if you want to format:
|
 |
Death Arte
Greenhorn
Joined: Feb 17, 2011
Posts: 21
|
|
@sri ramvaithiyanathan && Joe carco
Thank you very much! My problem has been solved..
Sorry for wrong posting..
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
Joe carco wrote:
The cast to Date is unnecessary; the parse() method already returns a Date object. Just write it like this:
You should avoid type casts as much as possible in your source code.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Death Arte
Greenhorn
Joined: Feb 17, 2011
Posts: 21
|
|
|
Wow! it really works.. Applying KISS principle... Thank you Jesper de Jong!
|
 |
 |
|
|
subject: Convert String to Date
|
|
|