Calendar roll & add

        Calendar.roll()
        Changes a specific unit and leaves 'larger' (in terms of time-month is 'larger' than day) units unchanged. The API example is that given a date of August 31, 1999, rolling by (Calendar.MONTH, yields April 30, 1999. That is, the DAY was changed to meet April's maximum, but the 'larger' unit, YEAR, was unchanged.

        Calendar.add()
        Will cause the next 'larger' unit to change, if necessary. That is, given a date of August 31, 1999, add(Calendar.MONTH, yields April 30, 2000. add() also forces a recalculation of milliseconds and all fields.

http://stackoverflow.com/questions/2504141/calendar-add-vs-roll-when-do-we-use-it

你可能感兴趣的:(calendar,区别,add,Roll)