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


Java LocalDateTime.isAfter方法代码示例

本文整理汇总了Java中java.time.LocalDateTime.isAfter方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.isAfter方法的具体用法?Java LocalDateTime.isAfter怎么用?Java LocalDateTime.isAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.LocalDateTime的用法示例。


在下文中一共展示了LocalDateTime.isAfter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: overlaps

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * overlaps if:
 * <pre>
 *  first.start is after second.start && first.start is before second.end
 *        | ---  first --- |
 *  | --- second --- |
 *
 *  second.start is after first.start && second.start is before first.end
 *  | ---  first --- |
 *        | --- second --- |
 * </pre>
 */
private boolean overlaps(LocalDateTime start, Duration duration, LocalDateTime lastStart, Duration lastDuration) {
    LocalDateTime firstStart;
    Duration firstDuration;
    LocalDateTime secondStart;
    Duration secondDuration;
    if (start.isBefore(lastStart)) {
        firstStart = start;
        firstDuration = duration;
        secondStart = lastStart;
        secondDuration = lastDuration;
    } else {
        firstStart = lastStart;
        firstDuration = lastDuration;
        secondStart = start;
        secondDuration = duration;
    }

    return firstStart.isAfter(secondStart) && firstStart.isBefore(secondStart.plus(secondDuration)) ||
            secondStart.isAfter(firstStart) && secondStart.isBefore(firstStart.plus(firstDuration))
            ;
}
 
开发者ID:michal-michaluk,项目名称:ddd-refactoring,代码行数:34,代码来源:PlannerServiceImpl.java

示例2: main

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static void main(String[] args) {
    LocalDateTime prizeCeremony = LocalDateTime.parse("2050-06-05T14:00:00");
    LocalDateTime dateTimeNow = LocalDateTime.now();

    if (prizeCeremony.getMonthValue() == 6)
        System.out.println("Can't invite president");
    else
        System.out.println("President invited");

    LocalDateTime chiefGuestDeparture = LocalDateTime.parse("2050-06-05T14:30:00");

    if (prizeCeremony.plusHours(2).isAfter(chiefGuestDeparture))
        System.out.println("Chief Guest will leave before ceremony completes");

    LocalDateTime eventMgrArrival = LocalDateTime.of(2050, 6, 5, 14, 14, 30, 0);
    if (eventMgrArrival.isAfter(prizeCeremony.minusHours(3)))
        System.out.println("Manager is supposed to arrive 3 hrs earlier");
}
 
开发者ID:huby,项目名称:java-se8-oca-study-guide,代码行数:19,代码来源:Main.java

示例3: onMouseDrag

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
public boolean onMouseDrag(MouseEvent e, double x, double y) {
    view.preparePopup(this.toString());
    dragged = true;
    if (isMoving) {
        long mins = (endTime.toEpochSecond(ZoneOffset.UTC) - startTime.toEpochSecond(ZoneOffset.UTC)) / 60;
        startTime = view.roundLocalDateTime(view.getMouseLocalDateTime().plusMinutes(minsOffset));
        endTime = startTime.plusMinutes(mins);
    } else {
        LocalDateTime newEndTime = view.roundLocalDateTime(view.getMouseLocalDateTime());
        if (newEndTime.isAfter(startTime)) {
            endTime = newEndTime;
        }
    }
    return true;
}
 
开发者ID:kiegroup,项目名称:optashift-employee-rostering,代码行数:17,代码来源:ShiftDrawable.java

示例4: assertEtaNotAfterRaidEnd

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static void assertEtaNotAfterRaidEnd(User user, Raid raid, LocalDateTime eta, LocaleService localeService) {
    if (eta.isAfter(raid.getEndOfRaid())) {
        throw new UserMessedUpException(user,
                localeService.getMessageFor(LocaleService.NO_ETA_AFTER_RAID,
                        localeService.getLocaleForUser(user), printTimeIfSameDay(eta),
                        printTimeIfSameDay(raid.getEndOfRaid())));
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:9,代码来源:Utils.java

示例5: createDownloadableHourList

import java.time.LocalDateTime; //导入方法依赖的package包/类
public List<LocalDateTime> createDownloadableHourList() {
    List<LocalDateTime> downloadableHourList = new ArrayList<>();
    Set<String> mjlogIndexIds = this.databaseService.findAllMjlogIndexIds();
    LocalDateTime from = LocalDateTime.of(LocalDate.now().minusDays(7), LocalTime.MIN);
    LocalDateTime to = LocalDateTime.now().truncatedTo(ChronoUnit.HOURS);
    for (LocalDateTime i = from; to.isAfter(i); i = i.plusHours(1)) {
        if (!mjlogIndexIds.contains(i.toString())) {
            downloadableHourList.add(i);
        }
    }
    return downloadableHourList;
}
 
开发者ID:CrazyBBB,项目名称:tenhou-visualizer,代码行数:13,代码来源:DownloadService.java

示例6: changeStartTime

import java.time.LocalDateTime; //导入方法依赖的package包/类
private void changeStartTime(MouseEvent evt) {
    LocalDateTime locationTime = dayView.getZonedDateTimeAt(evt.getX(), evt.getY()).toLocalDateTime();
    LocalDateTime time = grid(locationTime);

    LOGGER.finer("changing start time, time = " + time); //$NON-NLS-1$

    DraggedEntry draggedEntry = dayView.getDraggedEntry();

    if (isMinimumDuration(entry, entry.getEndAsLocalDateTime(), locationTime)) {

        Interval interval = draggedEntry.getInterval();

        LocalDate startDate = interval.getStartDate();
        LocalDate endDate = interval.getEndDate();

        LocalTime startTime;
        LocalTime endTime;

        if (locationTime.isAfter(entry.getEndAsLocalDateTime())) {
            startTime = entry.getEndTime();
            endTime = time.toLocalTime();
            endDate = time.toLocalDate();
        } else {
            startDate = time.toLocalDate();
            startTime = time.toLocalTime();
            endTime = entry.getEndTime();
        }

        LOGGER.finer("new interval: sd = " + startDate + ", st = " + startTime + ", ed = " + endDate + ", et = " + endTime);

        draggedEntry.setInterval(startDate, startTime, endDate, endTime);

        requestLayout();
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:36,代码来源:DayViewEditController.java

示例7: onCommand

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    long millis = System.currentTimeMillis();
    sender.sendMessage(ChatColor.GOLD + "The server time is currently " + ChatColor.YELLOW + DateTimeFormats.DAY_MTH_HR_MIN_AMPM.format(millis) + ChatColor.GOLD + '.');

    Map<LocalDateTime, String> scheduleMap = plugin.getEventScheduler().getScheduleMap();

    if (scheduleMap.isEmpty()) {
        sender.sendMessage(ChatColor.RED + "There is not an event schedule for after now.");
        return true;
    }

    LocalDateTime now = LocalDateTime.now(DateTimeFormats.SERVER_ZONE_ID);

    for (Map.Entry<LocalDateTime, String> entry : scheduleMap.entrySet()) {
        // Only show the events that haven't been yet.
        LocalDateTime scheduleDateTime = entry.getKey();
        if (now.isAfter(scheduleDateTime))
            continue;

        String monthName = scheduleDateTime.getMonth().getDisplayName(TextStyle.FULL, Locale.ENGLISH);
        String weekName = scheduleDateTime.getDayOfWeek().getDisplayName(TextStyle.SHORT, Locale.ENGLISH);
        sender.sendMessage(ChatColor.DARK_AQUA + WordUtils.capitalizeFully(entry.getValue()) + ChatColor.GRAY + " is the next event: " + ChatColor.AQUA + weekName + ' '
                + scheduleDateTime.getDayOfMonth() + ' ' + monthName + ChatColor.DARK_AQUA + " ("
                + DateTimeFormats.HR_MIN_AMPM.format(TimeUnit.HOURS.toMillis(scheduleDateTime.getHour()) + TimeUnit.MINUTES.toMillis(scheduleDateTime.getMinute())) + ')');

        return true;
    }

    sender.sendMessage(ChatColor.RED + "There is not an event scheduled after now.");
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:33,代码来源:KothNextArgument.java

示例8: exposureSecKillUrl

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
@Transactional(readOnly = true)
public JsonResult exposureSecKillUrl(Long id, Claims claims) throws Exception {
    String account = claims.getAudience();

    SpecialStockDTO specialStock = getOne(id);

    LocalDateTime startTime = specialStock.getStartTime(); // 秒杀开始时间
    LocalDateTime endTime = specialStock.getEndTime(); // 秒杀结束时间
    LocalDateTime nowTime = TimeUtil.nowDateTime(); //系统当前时间

    //若是秒杀未开始
    if (startTime.isAfter(nowTime)) {
        return new JsonResult(406, "秒杀活动未开始!");
        //秒杀已经结束
    } else if (endTime.isBefore(nowTime) || specialStock.getNumber() < 1) {
        return new JsonResult(406, "秒杀活动已经结束!");
        //秒杀处于开启窗口
    } else {
        // 检查是否秒杀过
        SpecialOrderModel order = specialOrderRepository.findByStockIdAndAccount(id, account);
        if (order != null) {
            return new JsonResult(403, "已秒杀成功,请勿重复秒杀!");
        }
        return new JsonResult(getMd5Url(id));
    }
}
 
开发者ID:lupindong,项目名称:xq_seckill_microservice,代码行数:28,代码来源:SpecialServiceImpl.java

示例9: isExpired

import java.time.LocalDateTime; //导入方法依赖的package包/类
public boolean isExpired() {
    LocalDateTime now = LocalDateTime.now();
    LocalDateTime generated = LocalDateTime.ofInstant(generatedTime.toInstant(), ZoneId.systemDefault());
    return now.isAfter(generated.plusDays(1));
}
 
开发者ID:JavaTrainingCourse,项目名称:obog-manager,代码行数:6,代码来源:PasswordResetRequest.java

示例10: getTags

import java.time.LocalDateTime; //导入方法依赖的package包/类
@GET
@Path("/{hashtag}")
public Response getTags(@PathParam("hashtag") final String hashtag,
                         @QueryParam("limit") @DefaultValue("25") final Integer limit,
                         @QueryParam("since") final Long since,
                         @QueryParam("username") final String username,
                         @Context GraphDatabaseService db) throws IOException {
    ArrayList<Map<String, Object>> results = new ArrayList<>();
    LocalDateTime dateTime;
    if (since == null) {
        dateTime = LocalDateTime.now(utc);
    } else {
        dateTime = LocalDateTime.ofEpochSecond(since, 0, ZoneOffset.UTC);
    }
    Long latest = dateTime.toEpochSecond(ZoneOffset.UTC);

    try (Transaction tx = db.beginTx()) {
        Node user = null;
        if (username != null) {
            user = Users.findUser(username, db);
        }

        Node tag = db.findNode(Labels.Tag, NAME, hashtag.toLowerCase());
        if (tag != null) {
            LocalDateTime earliestTag = LocalDateTime.ofEpochSecond((Long) tag.getProperty(TIME), 0, ZoneOffset.UTC);

            int count = 0;
            while (count < limit && (dateTime.isAfter(earliestTag))) {
                RelationshipType relType = RelationshipType.withName("TAGGED_ON_" +
                        dateTime.format(dateFormatter));

                for (Relationship r1 : tag.getRelationships(Direction.INCOMING, relType)) {
                    Node post = r1.getStartNode();
                    Map<String, Object> result = post.getAllProperties();
                    Long time = (Long) result.get("time");

                    if (count < limit && time < latest) {
                        Node author = getAuthor(post, time);
                        Map userProperties = author.getAllProperties();
                        result.put(USERNAME, userProperties.get(USERNAME));
                        result.put(NAME, userProperties.get(NAME));
                        result.put(HASH, userProperties.get(HASH));
                        result.put(LIKES, post.getDegree(RelationshipTypes.LIKES));
                        result.put(REPOSTS, post.getDegree(Direction.INCOMING)
                                - 1 // for the Posted Relationship Type
                                - post.getDegree(RelationshipTypes.LIKES)
                                - post.getDegree(RelationshipTypes.REPLIED_TO));
                        if (user != null) {
                            result.put(LIKED, userLikesPost(user, post));
                            result.put(REPOSTED, userRepostedPost(user, post));
                        }
                        results.add(result);
                        count++;
                    }
                }
                dateTime = dateTime.minusDays(1);
            }
            tx.success();
            results.sort(Comparator.comparing(m -> (Long) m.get(TIME), reverseOrder()));
        } else {
            throw TagExceptions.tagNotFound;
        }
    }
    return Response.ok().entity(objectMapper.writeValueAsString(results)).build();
}
 
开发者ID:maxdemarzi,项目名称:grittier_ext,代码行数:66,代码来源:Tags.java

示例11: createGroupIfConfigSaysSo

import java.time.LocalDateTime; //导入方法依赖的package包/类
private void createGroupIfConfigSaysSo(User user, GuildMessageReceivedEvent guildEvent, Config config,
                                       ClockService clockService, PokemonRaidInfo pokemonRaidInfo,
                                       LocalDateTime now, Raid createdRaid, MessageChannel channel) {
    // Auto create group for tier 5 bosses, if server config says to do so
    if (pokemonRaidInfo != null && pokemonRaidInfo.getBossTier() == 5) {
        LocalTime groupStart = null;
        // todo: fetch setting 10 minutes from server config?
        final LocalDateTime startOfRaid = getStartOfRaid(createdRaid.getEndOfRaid(), createdRaid.isExRaid());
        if (now.isBefore(startOfRaid)) {
            groupStart = startOfRaid.toLocalTime().plusMinutes(10);
        } else if (now.isAfter(startOfRaid) && now.plusMinutes(15).isBefore(createdRaid.getEndOfRaid())) {
            groupStart = now.toLocalTime().plusMinutes(10);
        }

        if (groupStart != null) {
            MessageChannel chn = config.getGroupCreationChannel(guildEvent.getGuild());
            MessageChannel channelToCreateGroupIn = channel;
            if (chn != null &&
                    config.getGroupCreationStrategy() == Config.RaidGroupCreationStrategy.NAMED_CHANNEL) {
                channelToCreateGroupIn = chn;
            }
            if (LOGGER.isDebugEnabled()) {
                if (channel != null) {
                    LOGGER.debug("Channel to use to create group: " + channel.getName());
                }
            }
            try {
                NewRaidGroupCommand.createRaidGroup(channelToCreateGroupIn, guildEvent.getGuild(), config, user,
                        config.getLocale(), groupStart, createdRaid.getId(), localeService, raidRepository,
                        botService, serverConfigRepository, pokemonRepository, gymRepository,
                        clockService, executorService, strategyService);
            } catch (Throwable t) {
                LOGGER.warn("Could not create raid group for server " + config.getServer() + " and raid " +
                createdRaid + ": " + t.getMessage());
            }
        }
    } else {
        if (pokemonRaidInfo == null) {
            LOGGER.debug("PokeRaidInfo was null for pokemon " + createdRaid.getPokemon().getName());
        }
    }
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:43,代码来源:GymHuntrRaidEventListener.java

示例12: isInInterval

import java.time.LocalDateTime; //导入方法依赖的package包/类
private static boolean isInInterval(LocalDateTime startTime, LocalDateTime endOfRaid,
                                    LocalDateTime startTimeTwo, LocalDateTime endOfRaidTwo) {
    return (startTime.isAfter(startTimeTwo) && startTime.isBefore(endOfRaidTwo)) ||
            (endOfRaid.isBefore(endOfRaidTwo) && endOfRaid.isAfter(startTimeTwo));
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:6,代码来源:Utils.java

示例13: isValueOnAxis

import java.time.LocalDateTime; //导入方法依赖的package包/类
public boolean isValueOnAxis(final LocalDateTime DATE_TIME) {
    return DATE_TIME.isAfter(getStart()) && DATE_TIME.isBefore(getEnd());
}
 
开发者ID:HanSolo,项目名称:charts,代码行数:4,代码来源:Axis.java

示例14: getOffsetInfo

import java.time.LocalDateTime; //导入方法依赖的package包/类
private Object getOffsetInfo(LocalDateTime dt) {
    if (savingsInstantTransitions.length == 0) {
        return standardOffsets[0];
    }
    // check if using last rules
    if (lastRules.length > 0 &&
            dt.isAfter(savingsLocalTransitions[savingsLocalTransitions.length - 1])) {
        ZoneOffsetTransition[] transArray = findTransitionArray(dt.getYear());
        Object info = null;
        for (ZoneOffsetTransition trans : transArray) {
            info = findOffsetInfo(dt, trans);
            if (info instanceof ZoneOffsetTransition || info.equals(trans.getOffsetBefore())) {
                return info;
            }
        }
        return info;
    }

    // using historic rules
    int index  = Arrays.binarySearch(savingsLocalTransitions, dt);
    if (index == -1) {
        // before first transition
        return wallOffsets[0];
    }
    if (index < 0) {
        // switch negative insert position to start of matched range
        index = -index - 2;
    } else if (index < savingsLocalTransitions.length - 1 &&
            savingsLocalTransitions[index].equals(savingsLocalTransitions[index + 1])) {
        // handle overlap immediately following gap
        index++;
    }
    if ((index & 1) == 0) {
        // gap or overlap
        LocalDateTime dtBefore = savingsLocalTransitions[index];
        LocalDateTime dtAfter = savingsLocalTransitions[index + 1];
        ZoneOffset offsetBefore = wallOffsets[index / 2];
        ZoneOffset offsetAfter = wallOffsets[index / 2 + 1];
        if (offsetAfter.getTotalSeconds() > offsetBefore.getTotalSeconds()) {
            // gap
            return new ZoneOffsetTransition(dtBefore, offsetBefore, offsetAfter);
        } else {
            // overlap
            return new ZoneOffsetTransition(dtAfter, offsetBefore, offsetAfter);
        }
    } else {
        // normal (neither gap or overlap)
        return wallOffsets[index / 2 + 1];
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:ZoneRules.java

示例15: isExpired

import java.time.LocalDateTime; //导入方法依赖的package包/类
public boolean isExpired(ClockService clockService) {
    final LocalDateTime currentDateTime = clockService.getCurrentDateTime();
    return currentDateTime.isAfter(endOfRaid);
}
 
开发者ID:magnusmickelsson,项目名称:pokeraidbot,代码行数:5,代码来源:RaidEntity.java


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