本文整理匯總了Java中java.time.LocalDateTime.isEqual方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalDateTime.isEqual方法的具體用法?Java LocalDateTime.isEqual怎麽用?Java LocalDateTime.isEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.isEqual方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateTimestampRanges
import java.time.LocalDateTime; //導入方法依賴的package包/類
private void calculateTimestampRanges() {
LocalDateTime endTime = chronoSeries.getEndLocalDateTime();
LocalDateTime itrTime = chronoSeries.getBeginLocalDateTime();
logger.debug("Starting range determine loop");
while (searchRange && (itrTime.isEqual(endTime) || itrTime.isBefore(endTime))) {
for (ChronoPattern chronoPattern : chronoPatternSeq) {
if (tempSkipUnit != null && chronoPattern != smallestPattern
&& chronoPattern.getChronoScaleUnit().getChronoUnit() == tempSkipUnit.getChronoUnit()) {
continue;
} else {
tempSkipUnit = null;
}
LocalDateTime startItrTime = itrTime;
logger.trace("Start itrTime: " + startItrTime);
itrTime = progressTime(endTime, itrTime, chronoPattern);
logger.trace("End itrTime: " + itrTime);
}
}
logger.debug("Finished range determine loop");
if (patternStartLocalDateTime != null && patternStartLocalDateTime.isBefore(chronoSeries.getBeginLocalDateTime())) {
patternStartLocalDateTime = chronoSeries.getBeginLocalDateTime();
}
if (patternEndLocalDateTime != null && patternEndLocalDateTime.isAfter(chronoSeries.getEndLocalDateTime())) {
patternEndLocalDateTime = chronoSeries.getEndLocalDateTime();
}
for (Instant[] instants : timestampRanges) {
rangeDuration = rangeDuration.plus(Duration.between(instants[0], instants[1]));
}
logger.debug("Range duration: " + rangeDuration);
}
示例2: createTickValues
import java.time.LocalDateTime; //導入方法依賴的package包/類
private List<LocalDateTime> createTickValues(final double WIDTH, final LocalDateTime START, final LocalDateTime END) {
List<LocalDateTime> dateList = new ArrayList<>();
LocalDateTime dateTime = LocalDateTime.now();
if (null == START || null == END) return dateList;
// The preferred gap which should be between two tick marks.
double majorTickSpace = 100;
double noOfTicks = WIDTH / majorTickSpace;
List<LocalDateTime> previousDateList = new ArrayList<>();
Interval previousInterval = Interval.values()[0];
// Starting with the greatest interval, add one of each dateTime unit.
for (Interval interval : Interval.values()) {
// Reset the dateTime.
dateTime = LocalDateTime.of(START.toLocalDate(), START.toLocalTime());
// Clear the list.
dateList.clear();
previousDateList.clear();
currentInterval = interval;
// Loop as long we exceeded the END bound.
while(dateTime.isBefore(END)) {
dateList.add(dateTime);
dateTime = dateTime.plus(interval.getAmount(), interval.getInterval());
}
// Then check the size of the list. If it is greater than the amount of ticks, take that list.
if (dateList.size() > noOfTicks) {
dateTime = LocalDateTime.of(START.toLocalDate(), START.toLocalTime());
// Recheck if the previous interval is better suited.
while(dateTime.isBefore(END) || dateTime.isEqual(END)) {
previousDateList.add(dateTime);
dateTime = dateTime.plus(previousInterval.getAmount(), previousInterval.getInterval());
}
break;
}
previousInterval = interval;
}
if (previousDateList.size() - noOfTicks > noOfTicks - dateList.size()) {
dateList = previousDateList;
currentInterval = previousInterval;
}
// At last add the END bound.
dateList.add(END);
List<LocalDateTime> evenDateList = makeDatesEven(dateList, dateTime);
// If there are at least three dates, check if the gap between the START date and the second date is at least half the gap of the second and third date.
// Do the same for the END bound.
// If gaps between dates are to small, remove one of them.
// This can occur, e.g. if the START bound is 25.12.2013 and years are shown. Then the next year shown would be 2014 (01.01.2014) which would be too narrow to 25.12.2013.
if (evenDateList.size() > 2) {
LocalDateTime secondDate = evenDateList.get(1);
LocalDateTime thirdDate = evenDateList.get(2);
LocalDateTime lastDate = evenDateList.get(dateList.size() - 2);
LocalDateTime previousLastDate = evenDateList.get(dateList.size() - 3);
// If the second date is too near by the START bound, remove it.
if (secondDate.toEpochSecond(ZoneOffset.ofHours(0)) - START.toEpochSecond(ZoneOffset.ofHours(0)) < thirdDate.toEpochSecond(ZoneOffset.ofHours(0)) - secondDate.toEpochSecond(ZoneOffset.ofHours(0))) {
evenDateList.remove(secondDate);
}
// If difference from the END bound to the last date is less than the half of the difference of the previous two dates,
// we better remove the last date, as it comes to close to the END bound.
if (END.toEpochSecond(ZoneOffset.ofHours(0)) - lastDate.toEpochSecond(ZoneOffset.ofHours(0)) < ((lastDate.toEpochSecond(ZoneOffset.ofHours(0)) - previousLastDate.toEpochSecond(ZoneOffset.ofHours(0)) * 0.5))) {
evenDateList.remove(lastDate);
}
}
return evenDateList;
}