gpt4 book ai didi

java - Calendar.DATE 和 Calendar.DAY_OF_MONTH 有什么区别?

转载 作者:行者123 更新时间:2023-12-05 08:26:40 29 4
gpt4 key购买 nike

我调用的时候有什么不同吗:

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 文档(强调我的):

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 ”表示一个意思相同的词。这两个常量表示同一事物并且可以互换。

此外,如果您查看代码,您会注意到这些常量定义了相同的值:

/**
* 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;

关于java - Calendar.DATE 和 Calendar.DAY_OF_MONTH 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52068844/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com