日历add()vs roll()什么时候我们使用它? [英] Calendar add() vs roll() when do we use it?

查看:125
本文介绍了日历add()vs roll()什么时候我们使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 add()根据日历规则,将指定的(已签署)时间量加到指定时间字段。



并且 roll()在不更改较大字段的情况下,在指定时间字段中添加指定的(有符号) >



我不能想到每天使用 roll() $ c> add()。



当我们使用 roll() add()



编辑1 Joda 的答案不接受!

解决方案


  • add() - 几乎总是如你所说的

  • roll在一个月内分发事件。该算法可以是进行若干天并放置事件,然后进一步进行。当到达月底时,它应该从头开始。因此 roll()


I know add() adds the specified (signed) amount of time to the given time field, based on the calendar's rules.

And roll() adds the specified (signed) single unit of time on the given time field without changing larger fields.

I can't think of an everyday usage of roll() I would do everything by add().

Can you help me out with examples when do we use roll() and when add()?

EDIT 1

Joda answers are not accepted!

解决方案

  • add() - almost always, as you said
  • roll() - for example you want to "dispense" events in one month. The algorithm may be to proceed a number of days and place the event, then proceed further. When the end of the month is reached, it should start over from the beginning. Hence roll().

这篇关于日历add()vs roll()什么时候我们使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆