Java Calendar get month name String

Description

Java Calendar get month name String

import java.text.DateFormatSymbols;
import java.util.Calendar;

public class Main {

  public static void main(String[] args) {
    Calendar gCal = Calendar.getInstance();

    int v = gCal.get(Calendar.MONTH);

    // Create new DateFormatSymbols instance to obtain 
    //the String value for dates
    DateFormatSymbols symbols = new DateFormatSymbols();
    String[] days = symbols.getMonths();
    System.out.println(days[v]);//from  w w w  .j  a  v a  2s  . c o  m

  }
}



PreviousNext

Related