如何在Java中获取两个日期之间的季度数
假设我们有以下两个日期-
LocalDate.of(2019, 3, 20);LocalDate.of(2019, 10, 25);
要获取上述两个日期之间的季度数,请使用QUARTER_YEARS-
IsoFields.QUARTER_YEARS.between(LocalDate.of(2019, 3, 20),LocalDate.of(2019, 10, 25));
示例
import java.time.LocalDate;import java.time.temporal.IsoFields;
public class Demo {
public static void main(String[] args) {
long quarters =
IsoFields.QUARTER_YEARS.between(LocalDate.of(2019, 3, 20), LocalDate.of(2019, 10, 25));
System.out.println("Quarters between the two dates = " + quarters);
}
}
输出结果
Quarters between the two dates = 2
以上是 如何在Java中获取两个日期之间的季度数 的全部内容, 来源链接: utcz.com/z/331281.html