本文整理汇总了Java中java.time.Instant.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java Instant.compareTo方法的具体用法?Java Instant.compareTo怎么用?Java Instant.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.Instant
的用法示例。
在下文中一共展示了Instant.compareTo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFilter
import java.time.Instant; //导入方法依赖的package包/类
private static Predicate<String> getFilter(Instant start, Instant end)
{
boolean nullStart = start == null;
boolean nullEnd = end == null;
if (nullStart && nullEnd) {
return s -> true;
}
else if (nullStart) {
return s -> DATE_FORMAT.parse(s, Instant::from).compareTo(end) <= 0;
}
else if (nullEnd) {
return s -> DATE_FORMAT.parse(s, Instant::from).compareTo(start) >= 0;
}
else {
return s -> {
Instant date = DATE_FORMAT.parse(s, Instant::from);
return date.compareTo(start) >= 0 && date.compareTo(end) <= 0;
};
}
}
示例2: updateDateRange
import java.time.Instant; //导入方法依赖的package包/类
private void updateDateRange(final TreeNode exactNode, final Range<Instant> range) {
final Range<Instant> original = exactNode.getDateRange();
Instant start = original.getStart();
Instant finish = original.getFinish();
if (start.isAfter(range.getStart())) {
start = range.getStart();
}
if (finish.isBefore(range.getFinish())) {
finish = range.getFinish();
}
if (start.compareTo(original.getStart()) != 0 ||
finish.compareTo(original.getFinish()) != 0) {
this.nextNodes.remove(new DatedNodeKey(exactNode.getValue(), original));
exactNode.setDateRange(new Range<Instant>(start, finish));
this.nextNodes.put(
new DatedNodeKey(exactNode.getValue(), exactNode.getDateRange()), exactNode);
}
}
示例3: MaxInstant
import java.time.Instant; //导入方法依赖的package包/类
public static Instant MaxInstant (Instant i1, Instant i2){
return i1.compareTo(i2) > 0 ? i1 : i2;
}
示例4: min
import java.time.Instant; //导入方法依赖的package包/类
public static Instant min(Instant a, Instant b) {
return a.compareTo(b) <= 0 ? a : b;
}
示例5: max
import java.time.Instant; //导入方法依赖的package包/类
public static Instant max(Instant a, Instant b) {
return a.compareTo(b) >= 0 ? a : b;
}
示例6: test_compareTo_ObjectNull
import java.time.Instant; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_compareTo_ObjectNull() {
Instant a = Instant.ofEpochSecond(0L, 0);
a.compareTo(null);
}
示例7: inRange
import java.time.Instant; //导入方法依赖的package包/类
private boolean inRange(final Instant time, final Range<Instant> range) {
final boolean isAfterStart = time.compareTo(range.getStart()) >= 0;
final boolean isBeforeEnd = time.compareTo(range.getFinish()) <= 0;
return isAfterStart && isBeforeEnd;
}