我知道 add() 根据日历的规则将指定的(签名的)时间量添加到给定的时间字段.
I know add() adds the specified (signed) amount of time to the given time field, based on the calendar's rules.
并且roll()在给定的时间字段上添加指定的(签名的)单个时间单位而不改变更大的字段.
And roll() adds the specified (signed) single unit of time on the given time field without changing larger fields.
我想不出 roll() 的日常用法,我会通过 add() 来做所有事情.
I can't think of an everyday usage of roll() I would do everything by add().
你能帮我举个例子,我们什么时候使用 roll() 以及什么时候使用 add()?
Can you help me out with examples when do we use roll() and when add()?
编辑 1
Joda 答案不被接受!
add() - 几乎总是如你所说roll() - 例如你想在一个月内分配"事件.该算法可能会进行几天并放置事件,然后继续进行.到了月底,应该从头开始.因此 roll().add() - almost always, as you saidroll() - 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().这篇关于Calendar add() vs roll() 我们什么时候使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
解析 ISO 8601 字符串本地日期时间,就像在 UTC 中Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期时间,就像在 UTC 中一样)
如何将公历字符串转换为公历?How to convert Gregorian string to Gregorian Calendar?(如何将公历字符串转换为公历?)
Java:GregorianCalendar 的最大值和最小值是什么/在哪Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
1582 年 10 月 15 日之前日期的日历到日期转换.公历Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日历到日期转换
java日历setFirstDayOfWeek不起作用java Calendar setFirstDayOfWeek not working(java日历setFirstDayOfWeek不起作用)
Java:获取当前星期几的值Java: getting current Day of the Week value(Java:获取当前星期几的值)