簡體   English   中英

與 Calendar.DATE 和 Calendar.DAY_OF_MONTH 有什么區別?

[英]What's the difference from Calendar.DATE and Calendar.DAY_OF_MONTH?

我打電話時有什么區別:

calendar.get(Calendar.DATE);
calendar.get(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DATE, day);
calendar.set(Calendar.DAY_OF_MONTH, day);

?

請參閱java.util.Calendar的 api 文檔(重點是我的):

公共靜態最終 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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM