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


Java DateTimeValueRange类代码示例

本文整理汇总了Java中java.time.calendrical.DateTimeValueRange的典型用法代码示例。如果您正苦于以下问题:Java DateTimeValueRange类的具体用法?Java DateTimeValueRange怎么用?Java DateTimeValueRange使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doPlusAdjustment

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
/**
 * Adds this period to the specified date-time object.
 * <p>
 * This method is not intended to be called by application code directly. Applications should use the
 * {@code plus(PlusAdjuster)} method on the date-time object passing this period as the argument.
 * <p>
 * The calculation will add the years, then months, then days, then nanos. Only non-zero amounts will be
 * added. If the date-time has a calendar system with a fixed number of months in a year, then the years and
 * months will be combined before being added.
 * 
 * @param dateTime the date-time object to adjust, not null
 * @return an object of the same type with the adjustment made, not null
 * @throws DateTimeException if unable to add
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public DateTime doPlusAdjustment(DateTime dateTime) {

  if ((this.years | this.months) != 0) {
    DateTimeValueRange startRange = Chrono.from(dateTime).range(MONTH_OF_YEAR);
    if (startRange.isFixed() && startRange.isIntValue()) {
      long monthCount = startRange.getMaximum() - startRange.getMinimum() + 1;
      dateTime = dateTime.plus(this.years * monthCount + this.months, MONTHS);
    } else {
      if (this.years != 0) {
        dateTime = dateTime.plus(this.years, YEARS);
      }
      if (this.months != 0) {
        dateTime = dateTime.plus(this.months, MONTHS);
      }
    }
  }
  if (this.days != 0) {
    dateTime = dateTime.plus(this.days, DAYS);
  }
  if (this.nanos != 0) {
    dateTime = dateTime.plus(this.nanos, NANOS);
  }
  return dateTime;
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:41,代码来源:Period.java

示例2: doMinusAdjustment

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
/**
 * Subtracts this period from the specified date-time object.
 * <p>
 * This method is not intended to be called by application code directly. Applications should use the
 * {@code minus(MinusAdjuster)} method on the date-time object passing this period as the argument.
 * <p>
 * The calculation will subtract the years, then months, then days, then nanos. Only non-zero amounts will
 * be subtracted. If the date-time has a calendar system with a fixed number of months in a year, then the
 * years and months will be combined before being subtracted.
 * 
 * @param dateTime the date-time object to adjust, not null
 * @return an object of the same type with the adjustment made, not null
 * @throws DateTimeException if unable to subtract
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public DateTime doMinusAdjustment(DateTime dateTime) {

  if ((this.years | this.months) != 0) {
    DateTimeValueRange startRange = Chrono.from(dateTime).range(MONTH_OF_YEAR);
    if (startRange.isFixed() && startRange.isIntValue()) {
      long monthCount = startRange.getMaximum() - startRange.getMinimum() + 1;
      dateTime = dateTime.minus(this.years * monthCount + this.months, MONTHS);
    } else {
      if (this.years != 0) {
        dateTime = dateTime.minus(this.years, YEARS);
      }
      if (this.months != 0) {
        dateTime = dateTime.minus(this.months, MONTHS);
      }
    }
  }
  if (this.days != 0) {
    dateTime = dateTime.minus(this.days, DAYS);
  }
  if (this.nanos != 0) {
    dateTime = dateTime.minus(this.nanos, NANOS);
  }
  return dateTime;
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:41,代码来源:Period.java

示例3: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    ChronoField f = (ChronoField) field;
    if (f.isDateField()) {
      switch (f) {
        case DAY_OF_MONTH:
          return DateTimeValueRange.of(1, lengthOfMonth());
        case DAY_OF_YEAR:
          return DateTimeValueRange.of(1, lengthOfYear());
        case ALIGNED_WEEK_OF_MONTH:
          return DateTimeValueRange.of(1, getMonth() == Month.FEBRUARY && isLeapYear() == false ? 4 : 5);
        case YEAR_OF_ERA:
          return (getYear() <= 0 ? DateTimeValueRange.of(1, MAX_YEAR + 1) : DateTimeValueRange.of(1, MAX_YEAR));
      }
      return field.range();
    }
    throw new DateTimeException("Unsupported field: " + field.getName());
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:23,代码来源:LocalDate.java

示例4: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    if (isSupported(field)) {
      ChronoField f = (ChronoField) field;
      switch (f) {
        case DAY_OF_YEAR:
          return actualRange(Calendar.DAY_OF_YEAR);
        case YEAR_OF_ERA:
          return actualRange(Calendar.YEAR);
      }
      return getChrono().range(f);
    }
    throw new DateTimeException("Unsupported field: " + field.getName());
  }
  return field.doRange(this);
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:19,代码来源:JapaneseDate.java

示例5: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    if (isSupported(field)) {
      ChronoField f = (ChronoField) field;
      switch (f) {
        case DAY_OF_MONTH:
          return DateTimeValueRange.of(1, lengthOfMonth());
        case DAY_OF_YEAR:
          return DateTimeValueRange.of(1, lengthOfYear());
        case ALIGNED_WEEK_OF_MONTH:
          return DateTimeValueRange.of(1, 5); // TODO
        case YEAR_OF_ERA:
          return DateTimeValueRange.of(1, 1000); // TODO
      }
      return getChrono().range(f);
    }
    throw new DateTimeException("Unsupported field: " + field.getName());
  }
  return field.doRange(this);
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:23,代码来源:HijrahDate.java

示例6: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    if (field == OFFSET_SECONDS) {
      return field.range();
    }
    return this.time.range(field);
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:12,代码来源:OffsetTime.java

示例7: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field == YEAR_OF_ERA) {
    return (getYear() <= 0 ? DateTimeValueRange.of(1, LocalDate.MAX_YEAR + 1) : DateTimeValueRange.of(1,
        LocalDate.MAX_YEAR));
  }
  return super.range(field);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:10,代码来源:YearMonth.java

示例8: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field == MONTH_OF_YEAR) {
    return field.range();
  } else if (field == DAY_OF_MONTH) {
    return DateTimeValueRange.of(1, getMonth().minLength(), getMonth().maxLength());
  }
  return super.range(field);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:11,代码来源:MonthDay.java

示例9: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    return this.dateTime.range(field);
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:9,代码来源:OffsetDateTime.java

示例10: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    if (((ChronoField) field).isTimeField()) {
      return field.range();
    }
    throw new DateTimeException("Unsupported field: " + field.getName());
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:12,代码来源:LocalTime.java

示例11: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    if (field == INSTANT_SECONDS || field == OFFSET_SECONDS) {
      return field.range();
    }
    return getDateTime().range(field);
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:12,代码来源:DefaultInterfaceChronoZonedDateTime.java

示例12: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    if (isSupported(field)) {
      return field.range();
    }
    throw new DateTimeException("Unsupported field: " + field.getName());
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:12,代码来源:DefaultInterfaceDateTimeAccessor.java

示例13: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field instanceof ChronoField) {
    ChronoField f = (ChronoField) field;
    return (f.isTimeField() ? this.time.range(field) : this.date.range(field));
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:10,代码来源:LocalDateTime.java

示例14: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field == YEAR_OF_ERA) {
    return (this.year <= 0 ? DateTimeValueRange.of(1, MAX_YEAR + 1) : DateTimeValueRange.of(1, MAX_YEAR));
  }
  return super.range(field);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:9,代码来源:Year.java

示例15: range

import java.time.calendrical.DateTimeValueRange; //导入依赖的package包/类
@Override
public DateTimeValueRange range(DateTimeField field) {

  if (field == OFFSET_SECONDS) {
    return field.range();
  } else if (field instanceof ChronoField) {
    throw new DateTimeException("Unsupported field: " + field.getName());
  }
  return field.doRange(this);
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:11,代码来源:ZoneOffset.java


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