java - 为什么使用 Java SimpleDateFormat 会减少一个月?

我正在使用 SimpleDateFormat 来显示这样的日历:

public String getDate()
{
    String DATE_FORMAT = "EEEE, dd/MM/yyyy HH:mm:ss";
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    System.err.println(date.getTime().getMonth());
    return sdf.format(date.getTime());
}

shell 返回 6 并显示:mardi, 06/07/2010 12:44:52

不可能吗?为什么?

谢谢

最佳答案

来自 Java API :

public int getMonth()

Returns a number representing the month that contains or begins with the instant in time represented by this Date object. The value returned is between 0 and 11, with the value 0 representing January.

https://stackoverflow.com/questions/2992381/

相关文章:

python - 如何获得小时 :minutes

c - C中孤花括号代码块的含义

android - 使用数据绑定(bind)时从 getTimeInMillis 获取日期

java - 意外的 java SimpleDateFormat 解析异常

javascript - 使用 jQuery 在输入框中显示一个小数点后 2 位的值,同时保持更高的

c# - 格式化难读的 try..catch..finally block ?

jsp - 如何将变量设置为小数点后 2 位

Java - 土耳其语或其他月份的日期格式

haskell - 新线 haskell

Python - 轻松将文本文件内容转换为字典值/键