• Post Reply Bookmark Topic Watch Topic
  • New Topic

parsing string to date  RSS feed

 
Greenhorn
Posts: 19
Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

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
 
Ranch Hand
Posts: 49
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Caleb

Use the class SimpleDateFormat

Heres the doc with good examples:

http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html


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.
 
Sheriff
Posts: 21201
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or use two SimpleDateFormat objects - one for parsing into a Date, the other for formatting that Date back into a String.
 
This will take every ounce of my mental strength! All for a tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!