Calendar.MONTH给出错误的值 [英] Calendar.MONTH gives wrong value

查看:395
本文介绍了Calendar.MONTH给出错误的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从日历使用得到实际的月份如下:

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));

根据系统设置设置 - >日期和放大器;时间实际月份为10,而 GET(Calendar.MONTH)返回09.

推荐答案

请记住,月值从 0 启动,因此实际上是月号 9

Keep in mind that months values start from 0, so October is actually month number 9.

<一个href="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Calendar.html#MONTH">http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Calendar.html#MONTH

这篇关于Calendar.MONTH给出错误的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆