Java Date get month int value, January starting from 1

Description

Java Date get month int value, January starting from 1

import java.util.Calendar;

public class Main {
  public static void main(String[] argv) {
    System.out.println(getNowMonth());
  }/*from   w w  w  .j a  v  a  2  s.c  o m*/

  public static int getNowMonth() {
    Calendar cc = Calendar.getInstance();
    return cc.get(Calendar.MONTH) + 1;
  }
}



PreviousNext

Related