java.time.temporal.Temporal.range()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(241)

本文整理了Java中java.time.temporal.Temporal.range()方法的一些代码示例,展示了Temporal.range()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Temporal.range()方法的具体详情如下:
包路径:java.time.temporal.Temporal
类名称:Temporal
方法名:range

Temporal.range介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

@Override
public final ValueRange range( TemporalField field )
{
  return temporal().range( field );
}

代码示例来源:origin: org.neo4j/neo4j-values

@Override
public final ValueRange range( TemporalField field )
{
  return temporal().range( field );
}

代码示例来源:origin: dremio/dremio-oss

@Override
 public Temporal adjustInto(Temporal temporal) {
  long adjustedDayOfMonth = Math.min(dayOfMonth, temporal.range(ChronoField.DAY_OF_MONTH).getMaximum());
  return temporal.with(ChronoField.DAY_OF_MONTH, adjustedDayOfMonth);
 }
};

代码示例来源:origin: com.github.seratch/java-time-backport

@Override
  public Temporal adjustInto(Temporal temporal) {
    switch (ordinal) {
      case 0: return temporal.with(DAY_OF_MONTH, 1);
      case 1: return temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum());
      case 2: return temporal.with(DAY_OF_MONTH, 1).plus(1, MONTHS);
      case 3: return temporal.with(DAY_OF_YEAR, 1);
      case 4: return temporal.with(DAY_OF_YEAR, temporal.range(DAY_OF_YEAR).getMaximum());
      case 5: return temporal.with(DAY_OF_YEAR, 1).plus(1, YEARS);
    }
    throw new IllegalStateException("Unreachable");
  }
}

代码示例来源:origin: org.omnifaces/omniutils

public static TemporalAdjuster nextDayOfMonth(int dayOfMonth) {
  validateDayOfMonth(dayOfMonth);
  return temporal -> {
    int currentDayOfMonth = temporal.get(DAY_OF_MONTH);
    if(currentDayOfMonth >= dayOfMonth || temporal.range(DAY_OF_MONTH).getMaximum() == currentDayOfMonth) {
      temporal = temporal.with(firstDayOfNextMonth());
    }
    ValueRange dayRange = temporal.range(DAY_OF_MONTH);
    int newDayOfMonth = dayOfMonth;
    if (dayRange.getMaximum() < dayOfMonth) {
      newDayOfMonth = (int) dayRange.getMaximum();
    }
    return temporal.with(DAY_OF_MONTH, newDayOfMonth);
  };
}

代码示例来源:origin: org.omnifaces/omniutils

public static TemporalAdjuster nextOrSameDayOfMonth(int dayOfMonth) {
  validateDayOfMonth(dayOfMonth);
  TemporalAdjuster nextDayOfMonth = nextDayOfMonth(dayOfMonth);
  return temporal -> {
    int currentDayOfMonth = temporal.get(DAY_OF_MONTH);
    if (currentDayOfMonth == dayOfMonth || (currentDayOfMonth < dayOfMonth && currentDayOfMonth == temporal.range(DAY_OF_MONTH).getMaximum())) {
      return temporal;
    }
    return temporal.with(nextDayOfMonth);
  };
}

代码示例来源:origin: org.threeten/threeten-extra

return (getYear() <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE));
return Temporal.super.range(field);

代码示例来源:origin: com.github.seratch/java-time-backport

return temporal.with(DAY_OF_MONTH, Math.min(temporal.range(DAY_OF_MONTH).getMaximum(), day));

代码示例来源:origin: com.github.seratch/java-time-backport

@Override
  public Temporal adjustInto(Temporal temporal) {
    if (ordinal >= 0) {
      Temporal temp = temporal.with(DAY_OF_MONTH, 1);
      int curDow = temp.get(DAY_OF_WEEK);
      int dowDiff = (dowValue - curDow + 7) % 7;
      dowDiff += (ordinal - 1L) * 7L;  // safe from overflow
      return temp.plus(dowDiff, DAYS);
    } else {
      Temporal temp = temporal.with(DAY_OF_MONTH, temporal.range(DAY_OF_MONTH).getMaximum());
      int curDow = temp.get(DAY_OF_WEEK);
      int daysDiff = dowValue - curDow;
      daysDiff = (daysDiff == 0 ? 0 : (daysDiff > 0 ? daysDiff - 7 : daysDiff));
      daysDiff -= (-ordinal - 1L) * 7L;  // safe from overflow
      return temp.plus(daysDiff, DAYS);
    }
  }
}

相关文章