Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I have a string with format "Mon Dec 03 00:00:00 IST 2012". I want to convert this string into Date. Any formats will do.
can try:
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy"); try { Date date = sdf.parse("Mon Dec 03 00:00:00 IST 2012"); } catch (ParseException e) { e.printStackTrace(); }
Add a comment
You can use parse() method of SimpleDateFormat class. Read the API documentation here.
parse()
date format of your string-represented date is:
DateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
Use a SimpleDateFormatter. You can find details about them here:
SimpleDateFormatter
SimpleDateFormat
DateFormat dateFormat = new SimpleDateFormat("E MMM dd HH:mm:ss zzz yyyy");
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.