ProgramixGenericLib v5.0.1

Class DateTools.OffsetTimeSource

  extended by com.programix.time.DateTools.OffsetTimeSource
All Implemented Interfaces:
Enclosing class:

public static class DateTools.OffsetTimeSource
extends Object
implements DateTools.TimeSource

Used to specify an offset (positive or negative) from 'now' that should be used for the DateTools.TimeSource.

Paul Hyde

Constructor Summary
DateTools.OffsetTimeSource(DateTime startDate)
          Create an offset to apply to the real current time.
DateTools.OffsetTimeSource(long offset)
          Create an offset to apply to the real current time.
Method Summary
 long getTime()
          Returns the number of milliseconds since 1970-01-01.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public DateTools.OffsetTimeSource(long offset)
Create an offset to apply to the real current time.

offset - the number of milliseconds to offset the real time by to create the simulated time. A positive number is an offset into the future; a negative is an offset into the past.


public DateTools.OffsetTimeSource(DateTime startDate)
Create an offset to apply to the real current time. The DateTime passed is the starting time to jump to as soon as this DateTools.TimeSource takes effect.

startDate - the date to use to calculate the offset from now.
Method Detail


public long getTime()
Description copied from interface: DateTools.TimeSource
Returns the number of milliseconds since 1970-01-01. Some implementations may choose to not use System.currentTimeMillis() as the source! This flexibility allows a VM-wide offset or time acceleration to be implemented. Keep in mind that if time is accelerated, wait(long msTimeout) and Thread.sleep(long msDuration) times requested throughout the VM will likely last too long.

Specified by:
getTime in interface DateTools.TimeSource

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.