Over a million developers have joined DZone.

Java: Format A Java Date From A String Using SimpleDateFormat

// 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);

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

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

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

{{ parent.tldr }}

{{ parent.urlSource.name }}