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


Java Month.JANUARY属性代码示例

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


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

示例1: getSchedule

public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate 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 && startDate.getMonth() == Month.JANUARY) {
      return new LocalDate[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but neither was the first day of the year");
  }
  final List<LocalDate> dates = new ArrayList<>();
  LocalDate date = startDate.with(TemporalAdjusters.firstDayOfYear());
  if (date.isBefore(startDate)) {
    date = date.plusYears(1);
  }
  while (!date.isAfter(endDate)) {
    dates.add(date);
    date = date.plusYears(1);
  }
  return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:FirstOfYearScheduleCalculator.java

示例2: getSchedule

public LocalDate[] getSchedule(final LocalDate startDate, final LocalDate 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() == _dayOfMonth) {
      return new LocalDate[] {startDate};
    }
    throw new IllegalArgumentException("Start date and end date were the same but their day of month was not the same as that required");
  }
  final List<LocalDate> dates = new ArrayList<>();
  int year = endDate.getYear();
  Month month = startDate.getMonth();
  LocalDate date = startDate.withMonth(month.getValue()).withDayOfMonth(_dayOfMonth);
  if (date.isBefore(startDate)) {
    month = month.plus(1);
    date = date.withMonth(month.getValue());
  }
  year = date.getYear();
  while (!date.isAfter(endDate)) {
    dates.add(date);
    month = month.plus(1);
    if (month == Month.JANUARY) {
      year++;
    }
    date = LocalDate.of(year, month.getValue(), _dayOfMonth);
  }
  return dates.toArray(EMPTY_LOCAL_DATE_ARRAY);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:29,代码来源:MonthlyScheduleOnDayCalculator.java


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