gpt4 book ai didi

java.time.ZoneOffset.compareTo()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 14:04:40 27 4
gpt4 key购买 nike

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

ZoneOffset.compareTo介绍

[英]Compares this offset to another offset in descending order.

The offsets are compared in the order that they occur for the same time of day around the world. Thus, an offset of +10:00 comes before an offset of +09:00 and so on down to -18:00.

The comparison is "consistent with equals", as defined by Comparable.
[中]按降序将此偏移量与另一个偏移量进行比较。
这些偏移量按世界各地一天中同一时间发生的顺序进行比较。因此,+10:00的偏移量先于+09:00的偏移量,依此类推到-18:00。
根据Comparable的定义,比较是“与相等一致的”。

代码示例

代码示例来源:origin: pholser/junit-quickcheck

/**
 * <p>Tells this generator to produce values within a specified
 * {@linkplain InRange#min() minimum} and/or {@linkplain InRange#max()
 * maximum}, inclusive, with uniform distribution.</p>
 *
 * <p>If an endpoint of the range is not specified, the generator will use
 * ZoneOffsets with values of either {@code ZoneOffset#MIN} or
 * {@code ZoneOffset#MAX} as appropriate.</p>
 *
 * <p>{@linkplain InRange#format()} is ignored. ZoneOffsets are always
 * parsed using their zone id.</p>
 *
 * @see ZoneOffset#of(String)
 * @param range annotation that gives the range's constraints
 */
public void configure(InRange range) {
  if (!defaultValueOf(InRange.class, "min").equals(range.min()))
    min = ZoneOffset.of(range.min());
  if (!defaultValueOf(InRange.class, "max").equals(range.max()))
    max = ZoneOffset.of(range.max());
  if (min.compareTo(max) > 0)
    throw new IllegalArgumentException(String.format("bad range, %s > %s", min, max));
}

代码示例来源:origin: io.permazen/permazen-coreapi

@Override
public int compare(ZoneOffset zoneOffset1, ZoneOffset zoneOffset2) {
  return zoneOffset1.compareTo(zoneOffset2);
}

代码示例来源:origin: org.jsimpledb/jsimpledb-coreapi

@Override
public int compare(ZoneOffset zoneOffset1, ZoneOffset zoneOffset2) {
  return zoneOffset1.compareTo(zoneOffset2);
}

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

/**
 * Returns a string describing this object.
 *
 * @return a string for debugging, not null
 */
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append("TransitionRule[")
    .append(offsetBefore.compareTo(offsetAfter) > 0 ? "Gap " : "Overlap ")
    .append(offsetBefore).append(" to ").append(offsetAfter).append(", ");
  if (dow != null) {
    if (dom == -1) {
      buf.append(dow.name()).append(" on or before last day of ").append(month.name());
    } else if (dom < 0) {
      buf.append(dow.name()).append(" on or before last day minus ").append(-dom - 1).append(" of ").append(month.name());
    } else {
      buf.append(dow.name()).append(" on or after ").append(month.name()).append(' ').append(dom);
    }
  } else {
    buf.append(month.name()).append(' ').append(dom);
  }
  buf.append(" at ").append(timeEndOfDay ? "24:00" : time.toString())
    .append(" ").append(timeDefinition)
    .append(", standard offset ").append(standardOffset)
    .append(']');
  return buf.toString();
}

代码示例来源:origin: com.pholser/junit-quickcheck-generators

/**
 * <p>Tells this generator to produce values within a specified
 * {@linkplain InRange#min() minimum} and/or {@linkplain InRange#max()
 * maximum}, inclusive, with uniform distribution.</p>
 *
 * <p>If an endpoint of the range is not specified, the generator will use
 * ZoneOffsets with values of either {@code ZoneOffset#MIN} or
 * {@code ZoneOffset#MAX} as appropriate.</p>
 *
 * <p>{@linkplain InRange#format()} is ignored. ZoneOffsets are always
 * parsed using their zone id.</p>
 *
 * @see ZoneOffset#of(String)
 * @param range annotation that gives the range's constraints
 */
public void configure(InRange range) {
  if (!defaultValueOf(InRange.class, "min").equals(range.min()))
    min = ZoneOffset.of(range.min());
  if (!defaultValueOf(InRange.class, "max").equals(range.max()))
    max = ZoneOffset.of(range.max());
  if (min.compareTo(max) > 0)
    throw new IllegalArgumentException(String.format("bad range, %s > %s", min, max));
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com