当前位置: 首页>>代码示例>>Java>>正文


Java ZonedDateTime.plusMonths方法代码示例

本文整理汇总了Java中org.threeten.bp.ZonedDateTime.plusMonths方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.plusMonths方法的具体用法?Java ZonedDateTime.plusMonths怎么用?Java ZonedDateTime.plusMonths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.threeten.bp.ZonedDateTime的用法示例。


在下文中一共展示了ZonedDateTime.plusMonths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSchedule

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
  ArgumentChecker.notNull(startDate, "start date");
  ArgumentChecker.notNull(endDate, "end date");
  ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
  if (startDate.equals(endDate)) {
    if (startDate.getDayOfMonth() == 1) {
      return new ZonedDateTime[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the first day of the month");
  }
  final List<ZonedDateTime> dates = new ArrayList<>();
  ZonedDateTime date = startDate.with(TemporalAdjusters.firstDayOfMonth());
  if (date.isBefore(startDate)) {
    date = date.plusMonths(1);
  }
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusMonths(1);
  }
  return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:FirstOfMonthScheduleCalculator.java

示例2: nextQuarter

import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
/**
 * Moves the date to the next IMM quarter month (at least one month in the future). The returned date is the same date in the month as the initial date.
 * @param date The reference date (as a ZonedDateTime).
 * @return The date in the next quarterly month.
 */
public static ZonedDateTime nextQuarter(final ZonedDateTime date) {
  ZonedDateTime result = date;
  do {
    result = result.plusMonths(1);
  } while (!FUTURES_QUARTERS.contains(result.getMonth()));
  return result;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:13,代码来源:InterestRateFuturesUtils.java


注:本文中的org.threeten.bp.ZonedDateTime.plusMonths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。