d*r 发帖数: 238 | 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 | d*r 发帖数: 238 | 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
| v**o 发帖数: 64 | 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
| c*****s 发帖数: 214 | 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
|
|