當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。