avatar
Calendar的日期问题# Java - 爪哇娇娃
q*s
1
J2ME中的Calendar类,我使用
int month = calendar.get(Calendar.MONTH);
获取的月数总是少一个月
文档中也没有明确说月份从0开始的呀。
多谢各位高人!
avatar
A*o
2
it is there.
MONTH
public static final int MONTH
Field number for get and set indicating the month. This is a calendar-
specific value. The first month of the year in the Gregorian and Julian
calendars is JANUARY which is 0; the last depends on the number of months in
a year.
avatar
A*o
3
However, don't ask me why the other two fields are 1 based. IMHO, it's
some very stupid designs on a core componet got carried over from
start.
avatar
q*s
4
多谢!j2me的api中我只找到你的第一句话!后来我用set把12作为参数加入,结果抛出
异常,所以我就估计从0开始的。
非常感谢!
avatar
m*t
5

Idiotic design notwithstanding, you are supposed to
use the constants, Calendar.JANUARY, etc.

【在 q***s 的大作中提到】
: 多谢!j2me的api中我只找到你的第一句话!后来我用set把12作为参数加入,结果抛出
: 异常,所以我就估计从0开始的。
: 非常感谢!

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。