org.joda.time.Seconds#secondsBetween ( )源码实例Demo

下面列出了org.joda.time.Seconds#secondsBetween ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Test
public void difference_between_two_dates_joda () {
	
	DateTime sinceGraduation = new DateTime(1984, 6, 4, 0, 0, GregorianChronology.getInstance());
	DateTime currentDate = new DateTime(); //current date

	Days diffInDays = Days.daysBetween(sinceGraduation, currentDate);
	Hours diffInHours = Hours.hoursBetween(sinceGraduation, currentDate);
	Minutes diffInMinutes = Minutes.minutesBetween(sinceGraduation, currentDate);
	Seconds seconds = Seconds.secondsBetween(sinceGraduation, currentDate);
	
	logger.info(diffInDays.getDays());
	logger.info(diffInHours.getHours());
	logger.info(diffInMinutes.getMinutes());
	logger.info(seconds.getSeconds());
	
	assertTrue(diffInDays.getDays() >= 10697);
	assertTrue(diffInHours.getHours() >= 256747);
	assertTrue(diffInMinutes.getMinutes() >= 15404876);
	assertTrue(seconds.getSeconds() >= 924292577);

}
 
源代码2 项目: actframework   文件: JobManager.java
public void on(DateTime instant, Runnable runnable) {
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("schedule runnable[%s] on %s", runnable, instant);
    }
    DateTime now = DateTime.now();
    E.illegalArgumentIf(instant.isBefore(now));
    Seconds seconds = Seconds.secondsBetween(now, instant);
    executor().schedule(wrap(runnable), seconds.getSeconds(), TimeUnit.SECONDS);
}
 
源代码3 项目: actframework   文件: JobManager.java
public <T> Future<T> on(DateTime instant, Callable<T> callable) {
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("schedule callable[%s] on %s", callable, instant);
    }
    DateTime now = DateTime.now();
    E.illegalArgumentIf(instant.isBefore(now));
    Seconds seconds = Seconds.secondsBetween(now, instant);
    return executor().schedule(callable, seconds.getSeconds(), TimeUnit.SECONDS);
}
 
源代码4 项目: actframework   文件: JobTrigger.java
private void delayedSchedule(JobManager manager, Job job) {
    DateTime now = DateTime.now();
    // add one seconds to prevent the next time be the current time (now)
    DateTime next = cronExpr.nextTimeAfter(now.plusSeconds(1));
    Seconds seconds = Seconds.secondsBetween(now, next);
    ScheduledFuture future = manager.executor().schedule(job, seconds.getSeconds(), TimeUnit.SECONDS);
    manager.futureScheduled(job.id(), future);
}
 
源代码5 项目: presto   文件: TestDateTimeFunctionsBase.java
private static Seconds secondsBetween(ReadableInstant start, ReadableInstant end)
{
    return Seconds.secondsBetween(start, end);
}
 
源代码6 项目: NoraUi   文件: CucumberHooks.java
protected static int getRemainingTime() {
    DateTime now = DateTime.now();
    Seconds pastTime = Seconds.secondsBetween(Context.getStartCurrentScenario(), now);
    int totalTimecalculated = pastTime.getSeconds() * Context.getDataInputProvider().getNbGherkinExample() / Context.getCurrentScenarioData();
    return totalTimecalculated - pastTime.getSeconds();
}
 
@Test
public void seconds_between_two_dates_in_java_with_joda () {

	// start day is 1 day in the past
	DateTime startDate = new DateTime().minusDays(1);
	DateTime endDate = new DateTime();
	
	Seconds seconds = Seconds.secondsBetween(startDate, endDate);
	
	int secondsInDay = seconds.getSeconds();
	
	assertEquals(86400, secondsInDay);
}
 
 方法所在类