HOw can i convert the String "2012-07-30" to Date object with same format 2012-07-30 which is date not a string. I've tried but i get the result in string. plz help

Recommended Answers

All 2 Replies

Date objects don't have a format, they just hold a date.
The SimpleDateFormat class has easy methods to parse strings like yours into Dates, and to display Dates in yopuir desired format.

As James said, a Date object no longer handle date the way you want. Even parse() method of Date class is deprecated. You can look at the SimpleDateFormat API.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.