Reputation: 518
Is there any difference when I called:
calendar.get(Calendar.DATE);
calendar.get(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DATE, day);
calendar.set(Calendar.DAY_OF_MONTH, day);
?
Upvotes: 3
Views: 4380
Reputation: 96444
See the api doc for java.util.Calendar (emphasis mine):
public static final int DAY_OF_MONTH
Field number for get and set indicating the day of the month. This is a synonym for DATE. The first day of the month has value 1.
“Synonym” means a word with the same meaning. these two constants mean the same thing and are interchangeable.
Also if you look in the code, you'll notice these constants are defined with the same value:
/**
* 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;
Upvotes: 14