Redian新闻
>
HELP! Question about Calendar
avatar
HELP! Question about Calendar# Java - 爪哇娇娃
d*r
1
Met a strange question:
I tried to set a date and output it:
Calendar c = new GregorianCalendar(2003, 12, 1); // set the calendar to
12/1/2003
System.out.println(DateFormat.getDateInstance().format(c)); // output
The output is Jan 1, 2004.
Who knows what's the problem?
I am using java 1.4.1
avatar
d*r
2
I tried another program:
Calendar c = new GregroianCalendar(2003, 12, 1); // c is Dec 1, 2003;
Date d = c.getTime();
c.setTime(d); // c changes to Jan 1, 2004;
What's wrong with my program?

【在 d*r 的大作中提到】
: Met a strange question:
: I tried to set a date and output it:
: Calendar c = new GregorianCalendar(2003, 12, 1); // set the calendar to
: 12/1/2003
: System.out.println(DateFormat.getDateInstance().format(c)); // output
: The output is Jan 1, 2004.
: Who knows what's the problem?
: I am using java 1.4.1

avatar
v*o
3
because the range of month is 0 ~ 11

【在 d*r 的大作中提到】
: Met a strange question:
: I tried to set a date and output it:
: Calendar c = new GregorianCalendar(2003, 12, 1); // set the calendar to
: 12/1/2003
: System.out.println(DateFormat.getDateInstance().format(c)); // output
: The output is Jan 1, 2004.
: Who knows what's the problem?
: I am using java 1.4.1

avatar
c*s
4


~~~~~~~~~~~~format(c.getTime());

【在 d*r 的大作中提到】
: Met a strange question:
: I tried to set a date and output it:
: Calendar c = new GregorianCalendar(2003, 12, 1); // set the calendar to
: 12/1/2003
: System.out.println(DateFormat.getDateInstance().format(c)); // output
: The output is Jan 1, 2004.
: Who knows what's the problem?
: I am using java 1.4.1

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