有人知道为什么 java.util.Caldendar 中的 MINUTE 方法返回不正确的分钟吗?
import java.util.Calendar;
public class Clock
{
// Instance fields
private Calendar time;
/**
* Constructor. Starts the clock at the current operating system time
*/
public Clock()
{
System.out.println(this.time.HOUR_OF_DAY+":"+this.time.MINUTE);
}
}
最佳答案
Calendar.MINUTE 不是实际的分钟,而是传递给“get()”以获取值的常量索引值。例如:
System.out.println(this.time.get(Calendar.HOUR_OF_DAY) + ":" + this.time.get(Calendar.MINUTE));
关于Java日历时间、分钟错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/404278/