Java GregorianCalendar What am I doing wrong? Wrong date?

Posted by saturation on Stack Overflow See other posts from Stack Overflow or by saturation
Published on 2010-05-31T13:08:48Z Indexed on 2010/05/31 13:12 UTC
Read the original article Hit count: 191

Filed under:
|
|
|

Hello I have a problem with GregorianCalendar.

What is wrong in there?

How outcome is 2010/6/1 and not 2010/05/31?

package test;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class Main {

    public static void main(String[] args) {
        Calendar cal = new GregorianCalendar(2010, 5, 31);
        System.out.println(cal.get(Calendar.YEAR) + "/" + cal.get(Calendar.MONTH) + "/" + cal.get(Calendar.DAY_OF_MONTH));
    }

}

© Stack Overflow or respective owner

Related posts about java

Related posts about date