当前位置: 首页>>代码示例>>Java>>正文


Java LocalDateTime.isEqual方法代码示例

本文整理汇总了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);
}
 
开发者ID:BFergerson,项目名称:Chronetic,代码行数:35,代码来源:ChronoRange.java

示例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;
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:74,代码来源:Axis.java


注:本文中的java.time.LocalDateTime.isEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。