This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes parsing string to date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "parsing string to date" Watch "parsing string to date" New topic

parsing string to date

Caleb Jhay

Joined: Apr 13, 2011
Posts: 18


I just want to ask if how can I convert this string " 11-15-2011" to yjis date format "11-Nov-2011"

Thank you and best regards
Jon Avadis
Ranch Hand

Joined: Jul 20, 2011
Posts: 49

Hi Caleb

Use the class SimpleDateFormat

Heres the doc with good examples:

Oh i just re-read your question. Where do you get the initial string from?
If your not getting it from a Date object, you might convert it with a custom method
by splitting and re-arranging the string.

Knowledge Reigns Supreme
Rob Spoor

Joined: Oct 27, 2005
Posts: 19672

Or use two SimpleDateFormat objects - one for parsing into a Date, the other for formatting that Date back into a String.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: parsing string to date