Just for context, here is how I am using joda pluggable millis-provider:
package systeminsights.infra.time
import java.util.concurrent.TimeUnit
import org.joda.time.{Period, DateTime, DateTimeUtils}
import org.drools.time.{TimerService, SessionPseudoClock}
import org.drools.time.impl.PseudoClockScheduler
object InsightClock {
implicit def toTimerService(ic: InsightClock): TimerService =
ic.droolsClock
}
class InsightClock(private val droolsClock: PseudoClockScheduler) {
DateTimeUtils.setMillisProvider(new DateTimeUtils.MillisProvider {
override def getMillis = droolsClock.getCurrentTime
});
def currentTime = new DateTime(droolsClock.getCurrentTime)
def advanceBy(amount: Long, unit: TimeUnit = TimeUnit.MILLISECONDS):
DateTime = new DateTime(droolsClock.advanceTime(amount, unit))
def advanceBy(amount: Period): DateTime =
advanceBy(amount.toStandardDuration.getMillis)
def advanceTo(time: DateTime): DateTime = advanceBy(time.getMillis -
droolsClock.getCurrentTime())
def withTime(time: DateTime): InsightClock = {
advanceTo(time)
this
}
}
--
View this message in context:
http://n2.nabble.com/Making-MillisProvider-public-and-pluggable-tp4134498p4135417.html
Sent from the Joda-Interest mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Joda-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/joda-interest