Java Program to format Month in MMMM format

Java 8Object Oriented ProgrammingProgramming

Set the month format as MMMM, while including the date-time format in SimpleDateFormat object.

Firstly, set the date object

Date dt = new Date();

Now, set the format for date-time

SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE MMMM dd yyyy kk:mm:ss");

Display the date with the format you want

dateFormat.format(dt)

The following is an example

Example

 Live Demo

import java.text.SimpleDateFormat;
import java.util.Date;
public class Demo {
   public static void main(String[] argv) throws Exception {
      Date dt = new Date();
      SimpleDateFormat dateFormat;
      dateFormat = new SimpleDateFormat("EEEE MMMM dd yyyy kk:mm:ss");
      System.out.println(dateFormat.format(dt));
   }
}

Output

Thursday November 22 2018 11:45:14
raja
Published on 19-Dec-2018 10:13:38
Advertisements