Java Program to Print the Months in Different Formats

Java program to print the months in different formats

import java.util.Calendar;
import java.util.Formatter;

public class ExMonthFormates {
  public static void main(String args[]) {
    // create object of date formatter class.
    Formatter fmt = new Formatter();

    // create object of calendar class.
    Calendar cal = Calendar.getInstance();
    fmt = new Formatter();

    // print month in different ways.
    fmt.format("%tB %tb %tm", cal, cal, cal);
    System.out.println(fmt);
  }
}

Output

November Nov 11
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment