Calendar add() vs roll() 我们什么时候使用它?

Calendar add() vs roll() when do we use it?(Calendar add() vs roll() 我们什么时候使用它?)
本文介绍了Calendar add() vs roll() 我们什么时候使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我知道 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 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().
    • 这篇关于Calendar add() vs roll() 我们什么时候使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

      本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)