我正在使用 SimpleDateFormat 来显示这样的日历:
I am using SimpleDateFormat to display a Calendar like this :
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
The shell returns 6 and the display : mardi, 06/07/2010 12:44:52
不可能吗?为什么?
谢谢
来自Java API:
public int getMonth()
public int getMonth()
返回一个表示月份的数字,该数字包含此 Date 对象所表示的时间点或以该时间点开始.返回值介于 0 到 11 之间,其中值 0 代表一月.
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.
这篇关于为什么使用 Java SimpleDateFormat 会减少一个月?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
解析 ISO 8601 字符串本地日期时间,就像在 UTC 中Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期时间,就像在 UTC 中一样)
如何将公历字符串转换为公历?How to convert Gregorian string to Gregorian Calendar?(如何将公历字符串转换为公历?)
Java:GregorianCalendar 的最大值和最小值是什么/在哪Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
1582 年 10 月 15 日之前日期的日历到日期转换.公历Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日历到日期转换
java日历setFirstDayOfWeek不起作用java Calendar setFirstDayOfWeek not working(java日历setFirstDayOfWeek不起作用)
Java:获取当前星期几的值Java: getting current Day of the Week value(Java:获取当前星期几的值)