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


Java LocalDateTime.until方法代码示例

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


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

示例1: deltaTimeMin

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * @return The difference between stop time and start time after adding interruption minutes or -1 if there is no stop time.
 */
public long deltaTimeMin() {
	if (this.timeStop != null) {
		LocalDateTime adjTimeStart = this.timeStart.plusMinutes(interruptionMin);
		long minutes = adjTimeStart.until(this.timeStop, ChronoUnit.MINUTES);		
		return minutes;
	}
	else {
		return -1;
	}
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:14,代码来源:TimeLog.java

示例2: estimatedPercent

import java.time.LocalDateTime; //导入方法依赖的package包/类
public double estimatedPercent(long blocks) {
        final LocalDateTime block100k = LocalDateTime.of(2017, Month.APRIL, 13, 23, 29, 49);
        final long minutes = block100k.until(LocalDateTime.now(), ChronoUnit.MINUTES);
        final int blockTime = 9;
        final long diff = minutes / blockTime;

        long estimatedHeight = 100000 + (diff / blockTime);
        return ((double) blocks / (double) estimatedHeight);

//        block100kTimestamp := time.Date(2017, time.April, 13, 23, 29, 49, 0, time.UTC)
//        blockTime := float64(9) // overestimate block time for better UX
//        diff := t.Sub(block100kTimestamp)
//        estimatedHeight := 100e3 + (diff.Minutes() / blockTime)
//        return types.BlockHeight(estimatedHeight + 0.5) // round to the nearest block
    }
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:16,代码来源:SiaUtil.java

示例3: getLabelBatchHisto

import java.time.LocalDateTime; //导入方法依赖的package包/类
/** Renvoie le label d'historique
 * @param batchHisto
 * @return
 */
private String getLabelBatchHisto(BatchHisto batchHisto){
	String txt = batchHisto.getStateBatchHisto()
			+" - "+applicationContext.getMessage("batch.histo.deb", new Object[]{batchHisto.getDateDebBatchHisto().format(formatterDateTime)}, UI.getCurrent().getLocale());
	if (batchHisto.getDateFinBatchHisto()!=null){
		LocalDateTime dateDeb = LocalDateTime.from(batchHisto.getDateDebBatchHisto());
		Long minutes = dateDeb.until(batchHisto.getDateFinBatchHisto(), ChronoUnit.MINUTES);
		dateDeb = dateDeb.plusMinutes(minutes);
		Long secondes = dateDeb.until(batchHisto.getDateFinBatchHisto(), ChronoUnit.SECONDS);
		txt += " - "+applicationContext.getMessage("batch.histo.fin", new Object[]{batchHisto.getDateFinBatchHisto().format(formatterDateTime)}, UI.getCurrent().getLocale());
		txt += " - "+applicationContext.getMessage("batch.histo.duree", new Object[]{getTimeFormated(minutes),getTimeFormated(secondes)}, UI.getCurrent().getLocale());
	}
	return txt;
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:18,代码来源:AdminBatchView.java

示例4: isSubjectOfNotification

import java.time.LocalDateTime; //导入方法依赖的package包/类
private boolean isSubjectOfNotification(GoogleEntry entry, LocalDateTime now) {
    List<GoogleEntryReminder> reminders = Lists.newArrayList();

    reminders.addAll(entry.getReminders());
    if (reminders.isEmpty()) {
        reminders.addAll(((GoogleCalendar) entry.getCalendar()).getDefaultReminders());
    }

    for (GoogleEntryReminder reminder : reminders) {
        if (reminder.getMethod() != GoogleEntryReminder.RemindMethod.POPUP) {
            continue;
        }

        if (reminder.getMinutes() == null || reminder.getMinutes() < 0) {
            continue;
        }

        if (!now.isBefore(entry.getStartAsLocalDateTime())) {
            continue;
        }

        long distanceMinutes = now.until(entry.getStartAsLocalDateTime(), ChronoUnit.MINUTES);
        if (distanceMinutes == reminder.getMinutes()) {
            return true;
        }
    }

    return false;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:30,代码来源:GoogleNotificationPopupThread.java

示例5: getDifference

import java.time.LocalDateTime; //导入方法依赖的package包/类
public static long getDifference(LocalDateTime sourceTime, LocalDateTime targetTime) {
    return targetTime.until(sourceTime, ChronoUnit.MINUTES);
}
 
开发者ID:SkyeBeFreeman,项目名称:ticket-booking-back-end,代码行数:4,代码来源:LocalDateTimeUtils.java

示例6: test_until_TemporalUnit

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit(LocalDateTime dt1, LocalDateTime dt2, TemporalUnit unit, long expected) {
    long amount = dt1.until(dt2, unit);
    assertEquals(amount, expected);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKLocalDateTime.java

示例7: test_until_TemporalUnit_negated

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test(dataProvider="periodUntilUnit")
public void test_until_TemporalUnit_negated(LocalDateTime dt1, LocalDateTime dt2, TemporalUnit unit, long expected) {
    long amount = dt2.until(dt1, unit);
    assertEquals(amount, -expected);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKLocalDateTime.java

示例8: test_until_invalidType

import java.time.LocalDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_until_invalidType() {
    LocalDateTime start = LocalDateTime.of(2010, 6, 30, 2, 30);
    start.until(LocalTime.of(11, 30), DAYS);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKLocalDateTime.java

示例9: getHoursBetween

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * 取得两个日期之间相差的小时数
 *
 * @param t1 开始长日期
 * @param t2 结束长日期
 * @return t1到t2间的日数,如果t2 在 t1之后,返回正数,否则返回负数
 */
public static long getHoursBetween(LocalDateTime t1, LocalDateTime t2) {
    return t1.until(t2, ChronoUnit.HOURS);
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:11,代码来源:DateUtils.java

示例10: getSecondsBetween

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * 取得两个日期之间相差的秒数
 *
 * @param t1 开始长日期
 * @param t2 结束长日期
 * @return t1到t2间的日数,如果t2 在 t1之后,返回正数,否则返回负数
 */
public static long getSecondsBetween(LocalDateTime t1, LocalDateTime t2) {
    return t1.until(t2, ChronoUnit.SECONDS);
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:11,代码来源:DateUtils.java

示例11: getMinutesBetween

import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
 * 取得两个日期之间相差的分钟
 *
 * @param t1 开始长日期
 * @param t2 结束长日期
 * @return t1到t2间的日数,如果t2 在 t1之后,返回正数,否则返回负数
 */
public static long getMinutesBetween(LocalDateTime t1, LocalDateTime t2) {
    return t1.until(t2, ChronoUnit.MINUTES);
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:11,代码来源:DateUtils.java


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