`
superfofo
  • 浏览: 128755 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics