import java.util.Calendar;
class A
{
public static void main(String args[])
{
System.out.println(Calendar.getInstance().MONTH);
}
}
我的电脑输出是:2
你们的呢?
为什么不对?
class A
{
public static void main(String args[])
{
System.out.println(Calendar.getInstance().MONTH);
}
}
我的电脑输出是: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;
System.out.println(Calendar.getInstance().get(Calendar.MONTH)+1);
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));
MONTH
public static final int MONTH指示月份的 get 和 set 的字段数字。这是一个特定于日历的值。一年中的第一个月是 JANUARY,它为 0;最后一个月取决于一年中的月份数。
API:
public static final int MONTH 2
你想拿當前月 但為什么去拿個常量呢?
不是取的值不對,而是你取的方法不對。
* <code>JANUARY</code> which is 0; the last depends on the number of months in a year.