日期:2014-05-20 浏览次数:20718 次
public class CalendarTest
{
public static void main(String[] args)
{
GregorianCalendar d = new GregorianCalendar();
int today = d.get(Calendar.DAY_OF_MONTH);
int month = d.get(Calendar.MONTH);
d.set(Calendar.DAY_OF_MONTH, 1);
int weekday = d.get(Calendar.DAY_OF_WEEK);
System.out.println(" " + weekday); // 打印出来的是1 12月1日星期天
System.out.println("hjahah" + Calendar.DAY_OF_WEEK);
// 打印出来的是7,d.set屏蔽掉直接打印Calendar.DAY_OF_WEEK也是7 为什么?不一样,这里的和
//上一句打印的不是同一内容,麻烦大神们给解释下.
}
}
GregorianCalendar d = new GregorianCalendar();
int weekday = d.get(Calendar.DAY_OF_WEEK);
System.out.println(" " + weekday);
d.set(Calendar.DAY_OF_MONTH, 1);
System.out.println("hjahah" + d.get(Calendar.DAY_OF_WEEK));
/**
* Field number for <code>get</code> and <code>set</code> indicating the
* era, e.g., AD or BC in the Julian calendar. This is a calendar-specific
* value; see subclass documentation.
*
* @see GregorianCalendar#AD
* @see GregorianCalendar#BC
*/
public final static int ERA = 0;
/**
* Field number for <code>get</code> and <code>set</code> indicating the
* year. This is a calendar-specific value; see subclass documentation.
*/
public final static int YEAR = 1;
/**
* 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 in the Gregorian and Julian calendars 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;
/**
* Field number for <code>get</code> and <code>set</code> indicating the
* week number within the current year. The first week of the year, as
* defined by <code>getFirstDayOfWeek()</code> and