Wednesday, July 3, 2024
HomeLanguagesJavaJava Program Format Time in MMMM Format

Java Program Format Time in MMMM Format

In Java, The MMM format for months is a short form of the month using 3 characters. SimpleDateFormat class is used for implementing this format in java and you can import this package by using the following code. 

import java.text.SimpleDateFormat

Example:

Months Name(MMMM Format) MMM Format
January Jan
February Feb
March Mar
April Apr
May May
June Jun
July Jul
August Aug
September Sep
October Oct
November Nov
December Dec

MMMM Format:

The MMMM format for months is the full name of the Month. For example -January, February, March, April, May, etc are the MMMM Format for the Month. 

Here, you will see the complete package that how you can use SimpleDateFormat class which extends DateFormat class. SimpleDateFormat class is also helpful to convert date to text format and also it’s parsing from text to date format and in normalization.

Class SimpleDateFormat
     java.lang.Object
        java.text.Format
            java.text.DateFormat
                 java.text.SimpleDateFormat

Example 1: Display Month in MMM and MMMM Format
 

Java




// Java program to display Month 
// in MMM and MMMM Format
import java.text.SimpleDateFormat;
import java.util.Date;
  
public class GFG {
    
public static void main(String[] argv) throws Exception {
      
    // Setting the date object
    Date dat = new Date();
    SimpleDateFormat dateFormat;
      
    // Setting MMM Format
    dateFormat = new SimpleDateFormat("MMM");
    System.out.println(dateFormat.format(dat));
      
    // Setting MMMM Format
    dateFormat = new SimpleDateFormat("MMMM");
    System.out.println(dateFormat.format(dat));
}
}


Output : 

Nov
November

Example 2: Display Date and Time in MMMM Format
 

Java




// Java Program to Display Date
// and Time in MMMM Format
import java.text.SimpleDateFormat;
import java.util.Date;
  
public class GFG {
    
public static void main(String[] argv) throws Exception {
      
    // Setting the date object
    Date dat = new Date();
    SimpleDateFormat dateFormat;
  
    // Setting the date and time in MMMM format
    dateFormat = new SimpleDateFormat("EEEE  dd MMMM yyyy kk:mm:ss");
    System.out.println(dateFormat.format(dat));
}
}


Output: 

Monday  02 November 2020 11:46:05

Nokonwaba Nkukhwana
Experience as a skilled Java developer and proven expertise in using tools and technical developments to drive improvements throughout a entire software development life cycle. I have extensive industry and full life cycle experience in a java based environment, along with exceptional analytical, design and problem solving capabilities combined with excellent communication skills and ability to work alongside teams to define and refine new functionality. Currently working in springboot projects(microservices). Considering the fact that change is good, I am always keen to new challenges and growth to sharpen my skills.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments