java.time.LocalTime.isAfter()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(210)

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

LocalTime.isAfter介绍

[英]Checks if this LocalTime is after the specified time.

The comparison is based on the time-line position of the time within a day.
[中]检查此LocalTime是否在指定的时间之后。
比较基于一天内时间的时间线位置。

代码示例

代码示例来源:origin: yu199195/Raincat

/**
 * 判断时间是否在指定的时间段之类.
 *
 * @param date  需要判断的时间
 * @param start 时间段的起始时间
 * @param end   时间段的截止时间
 * @return true or false
 */
public static boolean isBetween(final LocalTime date, final LocalTime start, final LocalTime end) {
  if (date == null || start == null || end == null) {
    throw new IllegalArgumentException("日期不能为空");
  }
  return date.isAfter(start) && date.isBefore(end);
}

代码示例来源:origin: oracle/helidon

boolean isValid(LocalTime nowTime) {
  return from.isBefore(nowTime) && to.isAfter(nowTime);
}

代码示例来源:origin: org.postgresql/postgresql

public synchronized String toString(LocalTime localTime) {
 sbuf.setLength(0);
 if (localTime.isAfter(MAX_TIME)) {
  return "24:00:00";
 }
 int nano = localTime.getNano();
 if (nanosExceed499(nano)) {
  // Technically speaking this is not a proper rounding, however
  // it relies on the fact that appendTime just truncates 000..999 nanosecond part
  localTime = localTime.plus(ONE_MICROSECOND);
 }
 appendTime(sbuf, localTime);
 return sbuf.toString();
}

代码示例来源:origin: org.assertj/assertj-core

/**
 * Verifies that the actual {@code LocalTime} is <b>strictly</b> after the given one.
 * <p>
 * Example :
 * <pre><code class='java'> assertThat(parse("13:00:00")).isAfter(parse("12:00:00"));</code></pre>
 *
 * @param other the given {@link LocalTime}.
 * @return this assertion object.
 * @throws AssertionError if the actual {@code LocalTime} is {@code null}.
 * @throws IllegalArgumentException if other {@code LocalTime} is {@code null}.
 * @throws AssertionError if the actual {@code LocalTime} is not strictly after the given one.
 */
public SELF isAfter(LocalTime other) {
 Objects.instance().assertNotNull(info, actual);
 assertLocalTimeParameterIsNotNull(other);
 if (!actual.isAfter(other)) {
  throw Failures.instance().failure(info, shouldBeAfter(actual, other));
 }
 return myself;
}

代码示例来源:origin: org.assertj/assertj-core

/**
 * Verifies that the actual {@code LocalTime} is before or equals to the given one.
 * <p>
 * Example :
 * <pre><code class='java'> assertThat(parse("12:00:00")).isBeforeOrEqualTo(parse("12:00:00"))
 *                                        .isBeforeOrEqualTo(parse("12:00:01"));</code></pre>
 *
 * @param other the given {@link LocalTime}.
 * @return this assertion object.
 * @throws AssertionError if the actual {@code LocalTime} is {@code null}.
 * @throws IllegalArgumentException if other {@code LocalTime} is {@code null}.
 * @throws AssertionError if the actual {@code LocalTime} is not before or equals to the given one.
 */
public SELF isBeforeOrEqualTo(LocalTime other) {
 Objects.instance().assertNotNull(info, actual);
 assertLocalTimeParameterIsNotNull(other);
 if (actual.isAfter(other)) {
  throw Failures.instance().failure(info, shouldBeBeforeOrEqualsTo(actual, other));
 }
 return myself;
}

代码示例来源:origin: joel-costigliola/assertj-core

/**
 * Verifies that the actual {@code LocalTime} is <b>strictly</b> after the given one.
 * <p>
 * Example :
 * <pre><code class='java'> assertThat(parse("13:00:00")).isAfter(parse("12:00:00"));</code></pre>
 *
 * @param other the given {@link LocalTime}.
 * @return this assertion object.
 * @throws AssertionError if the actual {@code LocalTime} is {@code null}.
 * @throws IllegalArgumentException if other {@code LocalTime} is {@code null}.
 * @throws AssertionError if the actual {@code LocalTime} is not strictly after the given one.
 */
public SELF isAfter(LocalTime other) {
 Objects.instance().assertNotNull(info, actual);
 assertLocalTimeParameterIsNotNull(other);
 if (!actual.isAfter(other)) {
  throw Failures.instance().failure(info, shouldBeAfter(actual, other));
 }
 return myself;
}

代码示例来源:origin: joel-costigliola/assertj-core

/**
 * Verifies that the actual {@code LocalTime} is before or equals to the given one.
 * <p>
 * Example :
 * <pre><code class='java'> assertThat(parse("12:00:00")).isBeforeOrEqualTo(parse("12:00:00"))
 *                                        .isBeforeOrEqualTo(parse("12:00:01"));</code></pre>
 *
 * @param other the given {@link LocalTime}.
 * @return this assertion object.
 * @throws AssertionError if the actual {@code LocalTime} is {@code null}.
 * @throws IllegalArgumentException if other {@code LocalTime} is {@code null}.
 * @throws AssertionError if the actual {@code LocalTime} is not before or equals to the given one.
 */
public SELF isBeforeOrEqualTo(LocalTime other) {
 Objects.instance().assertNotNull(info, actual);
 assertLocalTimeParameterIsNotNull(other);
 if (actual.isAfter(other)) {
  throw Failures.instance().failure(info, shouldBeBeforeOrEqualsTo(actual, other));
 }
 return myself;
}

代码示例来源:origin: benas/random-beans

@Override
protected void checkValues() {
  if (min.isAfter(max)) {
    throw new IllegalArgumentException("max must be after min");
  }
}

代码示例来源:origin: io.github.benas/random-beans

@Override
protected void checkValues() {
  if (min.isAfter(max)) {
    throw new IllegalArgumentException("max must be after min");
  }
}

代码示例来源:origin: stackoverflow.com

for (int li_tmp_ctr=0;   li_tmp_ctr < gi_total_elements;   ++li_tmp_ctr){
  LocalTime now = LocalTime.now( DateTimeZone.UTC );
  LocalTime limit = new LocalTime( IX_Container[li_tmp_ctr].utc_open_time );

  if (now.isAfter( limit) ){
    //  Write the information to the appropriate file. 
    lb_startFlag = true;
  }
}

代码示例来源:origin: stackoverflow.com

public static boolean isOpen(LocalTime start, LocalTime end, LocalTime time) {
 if (start.isAfter(end)) {
  return !time.isBefore(start) || !time.isAfter(end);
 } else {
  return !time.isBefore(start) && !time.isAfter(end);
 }
}

代码示例来源:origin: stackoverflow.com

LocalTime startTime = LocalTime.parse("07:00 PM", DateTimeFormat.forPattern("KK:mm a"));
 LocalTime endTime = LocalTime.parse("10:00 PM", DateTimeFormat.forPattern("KK:mm a"));
 LocalTime selected = new LocalTime(hourOfDay, minute);
 if (selected.isAfter(startTime) && selected.isBefore(endTime)) {
  // do your work
 }

代码示例来源:origin: stackoverflow.com

public static void main(String[] args) {
 LocalTime time = LocalTime.parse("11:22");
 System.out.println(isBetween(time, LocalTime.of(10, 0), LocalTime.of(18, 0)));
}

public static boolean isBetween(LocalTime candidate, LocalTime start, LocalTime end) {
 return !candidate.isBefore(start) && !candidate.isAfter(end);  // Inclusive.
}

代码示例来源:origin: stackoverflow.com

LocalTime localStartTime = new LocalTime( hoursStartTimeInt, minutesStartTimeInt);;
   LocalTime localEndTime = new LocalTime( hoursEndTimeInt, minutesEndTimeInt);;
   LocalTime twelveTime = new LocalTime(12,0);
   LocalTime sixTime = new LocalTime(06,0);
   localStartTime.isAfter(twelveTime);
   localStartTime.isBefore(sixTime);
   localEndTime.isAfter(twelveTime);
   localEndTime.isBefore(sixTime);

代码示例来源:origin: stackoverflow.com

LocalTime lowerBound = new LocalTime(10, 0);
LocalTime upperBound = new LocalTime(12, 30);

List<DateTime> filtered = new ArrayList<>();

for (DateTime dateTime : originals) {
  LocalTime localTime = new LocalTime(dateTime);
  if (lowerBound.isBefore(localTime) && upperBound.isAfter(localTime)) {
    filtered.add(dateTime);
  }
}

代码示例来源:origin: stackoverflow.com

public boolean isWithinInterval(LocalTime start, LocalTime end, LocalTime time) {
  if (start.isAfter(end)) {
    return !isWithinInterval(end, start, time);
  }
  // This assumes you want an inclusive start and an exclusive end point.
  return start.compareTo(time) <= 0 &&
      time.compareTo(end) < 0;
}

代码示例来源:origin: com.netflix.spinnaker.orca/orca-core

int indexOf(LocalTime current) {
 if (current.isBefore(this.start)) {
  return -1;
 } else if ((current.isAfter(this.start) || current.equals(this.start)) && (current.isBefore(this.end) || current.equals(this.end))) {
  return 0;
 } else {
  return 1;
 }
}

代码示例来源:origin: stackoverflow.com

public boolean isWithinInterval(LocalTime start, LocalTime end, LocalTime time) {
  if (start.isAfter(end)) {
    // Return true if the time is after (or at) start, *or* it's before end
    return time.compareTo(start) >= 0 ||
        time.compareTo(end) < 0;
  } else {
    return start.compareTo(time) <= 0 &&
        time.compareTo(end) < 0;
  }
}

代码示例来源:origin: nurkiewicz/rxjava-book-examples

private boolean isBusinessHour() {
  ZoneId zone = ZoneId.of("Europe/Warsaw");
  ZonedDateTime zdt = ZonedDateTime.now(zone);
  LocalTime localTime = zdt.toLocalTime();
  return !localTime.isBefore(BUSINESS_START)
      && !localTime.isAfter(BUSINESS_END);
}

代码示例来源:origin: zavtech/morpheus-core

/**
   * Checks that the value specified is in the bounds of this range
   * @param value     the value to check if in bounds
   * @return          true if in bounds
   */
  private boolean inBounds(LocalTime value) {
    return ascend ? value.compareTo(start()) >=0 && value.isBefore(end()) : value.compareTo(start()) <=0 && value.isAfter(end());
  }
}

相关文章