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


Java LocalDateTime.isAfter方法代码示例

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


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

示例1: addSessionReminder

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public void addSessionReminder(@NonNull Session session) {
    if (!isEnabled()) {
        Timber.d("SessionsReminder is not enable, skip adding session");
        return;
    }

    PendingIntent intent = createSessionReminderIntent(session);
    LocalDateTime now = LocalDateTime.now();
    LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
    if (!sessionStartTime.isAfter(now)) {
        Timber.w("Do not set reminder for passed session");
        return;
    }
    Timber.d("Setting reminder on %s", sessionStartTime);
    App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
}
 
开发者ID:Nilhcem,项目名称:droidconde-2016,代码行数:17,代码来源:SessionsReminder.java

示例2: shouldUpdateByPassword

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
private boolean shouldUpdateByPassword(LocalDateTime now, long refreshTime) {
    Instant instantRefresh = DateUtils.ofSecond(refreshTime);
    LocalDateTime targetRefresh = LocalDateTime.ofInstant(instantRefresh, ZoneId.systemDefault());
    return now.isAfter(targetRefresh);
}
 
开发者ID:TomeOkin,项目名称:LsPush,代码行数:6,代码来源:SyncService.java

示例3: toDurationFriendly

import org.threeten.bp.LocalDateTime; //导入方法依赖的package包/类
public static String toDurationFriendly(Context context, Date date) {
    final Instant instant = DateTimeUtils.toInstant(date);
    LocalDateTime target = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();

    LocalDateTime now = LocalDateTime.now();
    Duration duration;

    if (target.isAfter(now.minusMinutes(1))) {
        return context.getResources().getString(R.string.just_now);
    }

    if (target.isAfter(now.minusHours(1))) {
        duration = Duration.between(now, target);
        return context.getResources().getString(R.string.minutes_ago, Math.abs(duration.toMinutes()));
    }

    if (target.isAfter(now.minusDays(1))) {
        duration = Duration.between(now, target);
        return context.getResources().getString(R.string.hours_ago, Math.abs(duration.toHours()));
    }

    if (target.isAfter(now.minusWeeks(1))) {
        duration = Duration.between(target, now);
        return context.getResources().getString(R.string.days_ago, Math.abs(duration.toDays()));
    }

    // http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
    return target.format(DateTimeFormatter.ISO_LOCAL_DATE);

    //if (now.isEqual(target)) {
    //    duration = Duration.between(now, target);
    //    return target.format(DateTimeFormatter.ISO_TIME);
    //}

    // 本周
    //TemporalField chinaField = WeekFields.of(Locale.CHINA).dayOfWeek();
    //LocalDate start = now.with(chinaField, 1);
    //LocalDate end = now.with(chinaField, 7);
    //if (target.isAfter(start) && target.isBefore(end)) {
    //    return target.format()
    //}
    // 一周内
    //LocalDate from = now.minusDays(7);
    //if (target.isAfter(from)) {
    //
    //    return duration.toDays() + " 天前";
    //}
}
 
开发者ID:TomeOkin,项目名称:LsPush,代码行数:49,代码来源:DateUtils.java


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