我打电话时有什么区别:
calendar.get(Calendar.DATE);
calendar.get(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DATE, day);
calendar.set(Calendar.DAY_OF_MONTH, day);
Run Code Online (Sandbox Code Playgroud)
?
请参阅API文档以获取java.util.Calendar(重点是我的):
公共静态最终int DAY_OF_MONTH
get和set的字段编号,指示每月的日期。这是DATE的同义词。该月的第一天的值为1。
“ 同义词 ”是指具有相同含义的词。这两个常数含义相同,并且可以互换。
另外,如果您查看代码,则会注意到这些常量定义为相同的值:
/**
* Field number for <code>get</code> and <code>set</code> indicating the
* day of the month. This is a synonym for <code>DAY_OF_MONTH</code>.
* The first day of the month has value 1.
*
* @see #DAY_OF_MONTH
*/
public final static int DATE = 5;
/**
* Field number for <code>get</code> and <code>set</code> indicating the
* day of the month. This is a synonym for <code>DATE</code>.
* The first day of the month has value 1.
*
* @see #DATE
*/
public final static int DAY_OF_MONTH = 5;
Run Code Online (Sandbox Code Playgroud)