Calendar Class problems

前端 未结 6 682
梦谈多话
梦谈多话 2021-01-24 02:32

I am having problems with the Calendar Class.

Calendar cal = Calendar.getInstance ();

int iYear  = cal.get (Calendar.YEAR);         // get the curr         


        
6条回答
  •  深忆病人
    2021-01-24 02:57

    Please see the description provided for MONTH Constant in Calendar Class.

    Calendar.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.

    So if you want to set the date in calendar than use below code snippet.

    cal.set(2014, Calendar.FEBRUARY, 28);
    

    I think it will help you.

提交回复
热议问题