Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Java: Format A Java Date From A String Using SimpleDateFormat

DZone's Guide to

Java: Format A Java Date From A String Using SimpleDateFormat

·
Free Resource
// Takes a string in MMDDYYYY format and parses it into a date


  String date = "07032008";
  //Set the SimpleDateFormat and then parse
  //Here M stands for month in year, d for date in month, and y for year
  //For a complete list of pattern letters visit 
  
   http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html
  
  Date parsedDate = new SimpleDateFormat("MMddyyyy").parse(date);
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}