本文整理汇总了Java中java.time.ZonedDateTime.isBefore方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.isBefore方法的具体用法?Java ZonedDateTime.isBefore怎么用?Java ZonedDateTime.isBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.isBefore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRangeOfZonedDateTimes
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(dataProvider = "ZonedDateTimeRanges")
public void testRangeOfZonedDateTimes(ZonedDateTime start, ZonedDateTime end, Duration step, boolean parallel) {
final Range<ZonedDateTime> range = Range.of(start, end, step);
final Array<ZonedDateTime> array = range.toArray(parallel);
final boolean ascend = start.isBefore(end);
final int expectedLength = (int)Math.ceil(Math.abs((double)ChronoUnit.SECONDS.between(start, end)) / (double)step.getSeconds());
Assert.assertEquals(array.length(), expectedLength);
Assert.assertEquals(array.typeCode(), ArrayType.ZONED_DATETIME);
Assert.assertTrue(!array.style().isSparse());
Assert.assertEquals(range.start(), start, "The range start");
Assert.assertEquals(range.end(), end, "The range end");
ZonedDateTime expected = null;
for (int i=0; i<array.length(); ++i) {
final ZonedDateTime actual = array.getValue(i);
expected = expected == null ? start : ascend ? expected.plus(step) : expected.minus(step);
Assert.assertEquals(actual, expected, "Value matches at " + i);
Assert.assertTrue(ascend ? actual.compareTo(start) >=0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + i);
}
}
示例2: instantOfNextFrame
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public Instant instantOfNextFrame(final Instant instant) {
final ZonedDateTime britishTime = instant.atZone(BRITISH_TIME_ZONE);
final DayOfWeek britishDay = britishTime.getDayOfWeek();
if (britishDay != SUNDAY) {
return removeMinutesAndLess(britishTime).withHour(0).plus(1, DAYS).toInstant();
}
final ZonedDateTime britishTimeCorrectTimeValues = removeMinutesAndLess(britishTime).withHour(22);
if (britishTime.getDayOfWeek() == SUNDAY) {
if (britishTime.isBefore(britishTimeCorrectTimeValues)) {
return britishTimeCorrectTimeValues.toInstant();
}
return removeMinutesAndLess(britishTime).withHour(0).plus(2, DAYS).toInstant();
}
return britishTimeCorrectTimeValues.with(TemporalAdjusters.next(SUNDAY)).toInstant();
}
示例3: subseries
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
* Returns a new time series which is a view of a subset of the current series.
* <p>
* The new series has begin and end indexes which correspond to the bounds of the sub-set into the full series.<br>
* The tick of the series are shared between the original time series and the returned one (i.e. no copy).
* @param series the time series to get a sub-series of
* @param beginIndex the begin index (inclusive) of the time series
* @param duration the duration of the time series
* @return a constrained {@link TimeSeries time series} which is a sub-set of the current series
*/
public static TimeSeries subseries(TimeSeries series, int beginIndex, Duration duration) {
// Calculating the sub-series interval
ZonedDateTime beginInterval = series.getTick(beginIndex).getEndTime();
ZonedDateTime endInterval = beginInterval.plus(duration);
// Checking ticks belonging to the sub-series (starting at the provided index)
int subseriesNbTicks = 0;
int endIndex = series.getEndIndex();
for (int i = beginIndex; i <= endIndex; i++) {
// For each tick...
ZonedDateTime tickTime = series.getTick(i).getEndTime();
if (tickTime.isBefore(beginInterval) || !tickTime.isBefore(endInterval)) {
// Tick out of the interval
break;
}
// Tick in the interval
// --> Incrementing the number of ticks in the subseries
subseriesNbTicks++;
}
return new BaseTimeSeries(series, beginIndex, beginIndex + subseriesNbTicks - 1);
}
示例4: add
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public void add(EntryViewBase<?> view) {
if (entryViews == null) {
entryViews = new ArrayList<>();
}
entryViews.add(view);
Entry<?> entry = view.getEntry();
ZonedDateTime entryStartTime = entry.getStartAsZonedDateTime();
ZonedDateTime entryEndTime = entry.getEndAsZonedDateTime();
if (entry.isFullDay()) {
entryStartTime = entryStartTime.with(LocalTime.MIN);
entryEndTime = entryEndTime.with(LocalTime.MAX);
}
if (startTime == null || entryStartTime.isBefore(startTime)) {
startTime = entryStartTime;
}
if (endTime == null || entryEndTime.isAfter(endTime)) {
endTime = entryEndTime;
}
}
示例5: intersects
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public boolean intersects(EntryViewBase<?> view) {
if (startTime == null) {
/*
* The first added activity initializes the cluster.
*/
return true;
}
Entry<?> entry = view.getEntry();
ZonedDateTime entryStartTime = entry.getStartAsZonedDateTime();
ZonedDateTime entryEndTime = entry.getEndAsZonedDateTime();
if (entry.isFullDay()) {
entryStartTime = entryStartTime.with(LocalTime.MIN);
entryEndTime = entryEndTime.with(LocalTime.MAX);
}
return entryStartTime.isBefore(endTime)
&& entryEndTime.isAfter(startTime);
}
示例6: testRangeOfZonedDateTimes
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(dataProvider = "ZonedDateTimeRanges")
public void testRangeOfZonedDateTimes(ZonedDateTime start, ZonedDateTime end, Duration step, boolean parallel) {
final boolean ascend = start.isBefore(end);
final Range<ZonedDateTime> range = Range.of(start, end, step, v -> v.getHour() == 6);
final Array<ZonedDateTime> array = range.toArray(parallel);
final ZonedDateTime first = array.first(v -> true).map(ArrayValue::getValue).get();
final ZonedDateTime last = array.last(v -> true).map(ArrayValue::getValue).get();
Assert.assertEquals(array.typeCode(), ArrayType.ZONED_DATETIME);
Assert.assertTrue(!array.style().isSparse());
Assert.assertEquals(range.start(), start, "The range start");
Assert.assertEquals(range.end(), end, "The range end");
int index = 0;
ZonedDateTime value = first;
while (ascend ? value.isBefore(last) : value.isAfter(last)) {
final ZonedDateTime actual = array.getValue(index);
Assert.assertEquals(actual, value, "Value matches at " + index);
Assert.assertTrue(ascend ? actual.compareTo(start) >= 0 && actual.isBefore(end) : actual.compareTo(start) <= 0 && actual.isAfter(end), "Value in bounds at " + index);
value = ascend ? value.plus(step) : value.minus(step);
while (value.getHour() == 6) value = ascend ? value.plus(step) : value.minus(step);
index++;
}
}
示例7: areInSameTimeFrame
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public boolean areInSameTimeFrame(final Instant instant1, final Instant instant2) {
final ZonedDateTime britishTime = instant1.atZone(BRITISH_TIME_ZONE);
final DayOfWeek britishDay = britishTime.getDayOfWeek();
final ZonedDateTime localBase = britishTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
final ZonedDateTime start;
final ZonedDateTime end;
if (britishDay == SUNDAY) {
if (britishTime.isBefore(localBase.withHour(22))) {
start = localBase;
end = localBase.withHour(22);
} else {
start = localBase.withHour(22);
end = localBase.plusDays(2);
}
} else if (britishDay == MONDAY) {
start = localBase.minusDays(1).withHour(22);
end = localBase.plusDays(1);
} else {
start = localBase;
end = localBase.plusDays(1);
}
return instant2.equals(start.toInstant())
|| (instant2.isAfter(start.toInstant()) && instant2.isBefore(end.toInstant()));
}
示例8: isClaimedCase
import java.time.ZonedDateTime; //导入方法依赖的package包/类
private boolean isClaimedCase(GameServer s, String key) {
if (s.getExpirationDate() == null) {
return false;
}
ZonedDateTime now = ZonedDateTime.now();
return "claimed".equals(key) && now.isBefore(s.getExpirationDate());
}
示例9: getMinOfMaxTime
import java.time.ZonedDateTime; //导入方法依赖的package包/类
private ZonedDateTime getMinOfMaxTime(ObjLog log){
List<CsLogCurveInfo> curveInfos = log.getLogCurveInfo();
ZonedDateTime maxDate = null;
for (CsLogCurveInfo curveInfo : curveInfos) {
if (curveInfo.getMaxDateTimeIndex() != null) {
ZonedDateTime currentMaxDate = curveInfo.getMaxDateTimeIndex().toGregorianCalendar().toZonedDateTime();
if (maxDate == null)
maxDate = currentMaxDate;
else if (currentMaxDate.isBefore(maxDate))
maxDate = currentMaxDate;
}
}
return maxDate;
}
示例10: buildEmptyTicks
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
* Builds a list of empty ticks.
* @param beginTime the begin time of the whole period
* @param endTime the end time of the whole period
* @param duration the tick duration (in seconds)
* @return the list of empty ticks
*/
private static List<Tick> buildEmptyTicks(ZonedDateTime beginTime, ZonedDateTime endTime, int duration) {
List<Tick> emptyTicks = new ArrayList<>();
Duration tickDuration = Duration.ofSeconds(duration);
ZonedDateTime tickEndTime = beginTime;
do {
tickEndTime = tickEndTime.plus(tickDuration);
emptyTicks.add(new BaseTick(tickDuration, tickEndTime));
} while (tickEndTime.isBefore(endTime));
return emptyTicks;
}
示例11: intersect
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static boolean intersect(ZonedDateTime aStart, ZonedDateTime aEnd,
ZonedDateTime bStart, ZonedDateTime bEnd) {
// Same start time or same end time?
if (aStart.equals(bStart) || aEnd.equals(bEnd)) {
return true;
}
return aStart.isBefore(bEnd) && aEnd.isAfter(bStart);
}
示例12: computestart
import java.time.ZonedDateTime; //导入方法依赖的package包/类
private static void computestart() {
int startHour = 14;
int startMinute = 10;
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
ZonedDateTime start = now.withHour(startHour).withMinute(startMinute).withSecond(0).withNano(0);
if (start.isBefore(now)) start = start.plusDays(1);
long initialDelay = ChronoUnit.MINUTES.between(now, start);
System.out.println(now);
System.out.println(start);
System.out.println(initialDelay + " -> " + initialDelay/60);
}
示例13: getDelay
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static long getDelay() {
ZonedDateTime nextDate = ZonedDateTime.now()
.with(DayOfWeek.SUNDAY)
.withHour(12)
.withMinute(0)
.withSecond(0);
if(nextDate.isBefore(ZonedDateTime.now())) {
nextDate = nextDate.plusWeeks(1);
}
return TimeUtils.getMillisUntil(nextDate.toInstant());
}
示例14: isDatumEindeVolgenVerstreken
import java.time.ZonedDateTime; //导入方法依赖的package包/类
private boolean isDatumEindeVolgenVerstreken(final Afnemerindicatie persoonAfnemerindicatie, final ZonedDateTime peilMoment) {
if (persoonAfnemerindicatie.getDatumEindeVolgen() == null) {
return false;
}
final ZonedDateTime datumEindeVolgen = DatumUtil.vanIntegerNaarLocalDate(persoonAfnemerindicatie.getDatumEindeVolgen())
.atStartOfDay(DatumUtil.NL_ZONE_ID);
return datumEindeVolgen.isBefore(peilMoment) || datumEindeVolgen.isEqual(peilMoment);
}
示例15: controleerFormeelPeilmomentTovGBASystematiek
import java.time.ZonedDateTime; //导入方法依赖的package包/类
private void controleerFormeelPeilmomentTovGBASystematiek(final ZonedDateTime tijdstipLaatsteWijzigingGBASystematiek,
final GeefDetailsPersoonVerzoek bevragingVerzoek) throws StapMeldingException {
final GeefDetailsPersoonVerzoek.HistorieFilterParameters historieParams = bevragingVerzoek.getParameters()
.getHistorieFilterParameters();
if (tijdstipLaatsteWijzigingGBASystematiek != null && historieParams != null && historieParams.getPeilMomentFormeelResultaat() != null) {
final ZonedDateTime peilMomentFormeelResultaat =
DatumFormatterUtil.vanXsdDatumTijdNaarZonedDateTime(historieParams.getPeilMomentFormeelResultaat());
if (peilMomentFormeelResultaat != null && peilMomentFormeelResultaat.isBefore(tijdstipLaatsteWijzigingGBASystematiek)) {
throw new StapMeldingException(Regel.R2300);
}
}
}