本文整理汇总了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);
}