Creating Calendar objectssuggest change
Calendar objects can be created by using
getInstance() or by using the constructor
It’s important to notice that months in
Calendar are zero based, which means that JANUARY is represented by an
int value 0. In order to provide a better code, always use
Calendar constants, such as
Calendar.JANUARY to avoid misunderstandings.
Calendar calendar = Calendar.getInstance(); Calendar gregorianCalendar = new GregorianCalendar(); Calendar gregorianCalendarAtSpecificDay = new GregorianCalendar(2016, Calendar.JANUARY, 1); Calendar gregorianCalendarAtSpecificDayAndTime = new GregorianCalendar(2016, Calendar.JANUARY, 1, 6, 55, 10);
Note: Always use the month constants: The numeric representation is misleading, e.g.
Calendar.JANUARY has the value