This example will demonstrate how to format a date from a pattern string while using java.text.SimpleDateFormat, String.format, Java 8 date time api, Joda’s DateTimeFormat and apache commons DateFormatUtils.format. DateFormat contains predefined date formats in the JDK which can be used in substitue of a string pattern. January 15, 1967, the date used in the examples below, was the date which the first super bowl was played between Kansas City Chiefs and Green Bay Packers.
Straight up Java
SimpleDateFormat
String.format
Java 8 Date and Time API
The DateTimeFormatter.ofPattern will construct formatter with a MM/dd/YYYY format. Then passing the formatter to LocalDate.format will format this date using the MM/dd/YYYY formatter.