import java.util.Calendar;
class A
{
public static void main(String args[])
{
System.out.println(Calendar.getInstance().MONTH);
}
}
我的电脑输出是:2
你们的呢?
为什么不对?

解决方案 »

  1.   

    Calendar.MONTH是java.util.*定义的常量值,定好了为2.
    java代码:/**
         * Field number for <code>get</code> and <code>set</code> indicating the
         * month. This is a calendar-specific value. The first month of the year is
         * <code>JANUARY</code> which is 0; the last depends on the number of months in a year.
         * @see #JANUARY
         * @see #FEBRUARY
         * @see #MARCH
         * @see #APRIL
         * @see #MAY
         * @see #JUNE
         * @see #JULY
         * @see #AUGUST
         * @see #SEPTEMBER
         * @see #OCTOBER
         * @see #NOVEMBER
         * @see #DECEMBER
         * @see #UNDECIMBER
         */
        public final static int MONTH = 2;
      

  2.   

    你那个是获得的类型。要想得到月份可以这样
    System.out.println(Calendar.getInstance().get(Calendar.MONTH)+1);
      

  3.   

    可以这样获得:
    String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); Calendar calendar = new GregorianCalendar(pdt); System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
      

  4.   

    楼主你这个问题很无聊哦。MONTH是指示月份的 get 和 set 的字段数字。这是一个常量,是不会改变的。你要想获得月份,应该使用get(Calendar.MONTH)
      

  5.   

    是常量2,如果想得到系统月份先要getTime,然后再取月份
      

  6.   

    要加1才对啊
    MONTH
    public static final int MONTH指示月份的 get 和 set 的字段数字。这是一个特定于日历的值。一年中的第一个月是 JANUARY,它为 0;最后一个月取决于一年中的月份数。 
      

  7.   

    Calendar.getInstance().MONTH这个是内部的常量,获得月份是cal.get(Calendar.MONTH)+1这个才是
      

  8.   

    System.out.println(Calendar.getInstance().MONTH);
    API:
    public static final int MONTH 2 
    你想拿當前月 但為什么去拿個常量呢?
    不是取的值不對,而是你取的方法不對。
      

  9.   


     * <code>JANUARY</code> which is 0; the last depends on the number of months in a year.