本文整理匯總了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;
}
}
示例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
}
示例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;
}
示例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;
}
示例5: getDifference
import java.time.LocalDateTime; //導入方法依賴的package包/類
public static long getDifference(LocalDateTime sourceTime, LocalDateTime targetTime) {
return targetTime.until(sourceTime, ChronoUnit.MINUTES);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}