Java SimpleDateFormat format Date to String as "February 24, 2020"

Description

Java SimpleDateFormat format Date to String as "February 24, 2020"

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
  public static void main(String[] args) {
    // Create a formatter with a pattern dd/MM/yyyy.
    SimpleDateFormat simpleFormatter = new SimpleDateFormat("MMMM dd, yyyy");

    // Get current date
    Date today = new Date();

    // Format the current date
    String formattedDate = simpleFormatter.format(today);

    // Print the date
    System.out.println("Today is (MMMM dd, yyyy): " + formattedDate);
  }//  w ww . j a va 2  s .co m
}



PreviousNext

Related