Java Calendar format to String like "February 24 2020"

Description

Java Calendar format to String like "February 24 2020"

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Main {

  public static void main(String[] args) {
    // Create new calendar
    Calendar cal = Calendar.getInstance();

    // Create instance of SimpleDateFormat class using pattern
    SimpleDateFormat dateFormatter1 = new SimpleDateFormat("MMMMM dd yyyy");
    String result = null;//from  ww  w .  j  a  va2s  . c  o  m

    result = dateFormatter1.format(cal.getTime());
    System.out.println(result);


  }
}



PreviousNext

Related