Calendar.MONTH 给出了错误的值 [英] Calendar.MONTH gives wrong value
本文介绍了Calendar.MONTH 给出了错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下方法从 Calendar
获取实际月份:
I'm trying to get the actual month from the Calendar
using the following:
Calendar c = Calendar.getInstance();
String time = String.valueOf(c.get(Calendar.MONTH));
根据系统设置Settings --> Date & Time"实际月份为10,而get(Calendar.MONTH)
返回09.
According the system settings "Settings --> Date & Time" actual month is 10 while get(Calendar.MONTH)
returns 09.
推荐答案
记住月份值是从0
开始的,所以October
实际上是月份号9
.
Keep in mind that months values start from 0
, so October
is actually month number 9
.
http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Calendar.html#MONTH
这篇关于Calendar.MONTH 给出了错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文