org.apache.solr.common.util

## Class TimeSource

- java.lang.Object
- - org.apache.solr.common.util.TimeSource

Direct Known Subclasses:
  TimeSource.CurrentTimeSource, TimeSource.NanoTimeSource, TimeSource.SimTimeSource

    public abstract class TimeSource
    extends Object

Source of time. NOTE: depending on implementation returned values may not be related in any way to the current Epoch or calendar time, and they may even be negative - but the API guarantees that they are always monotonically increasing.

### Nested Class Summary

Nested Classes
`static class` `TimeSource.CurrentTimeSource` Implementation that uses `System.currentTimeMillis()`.
`static class` `TimeSource.NanoTimeSource` Implementation that uses `System.nanoTime()`.
`static class` `TimeSource.SimTimeSource` Implementation that uses `NANO_TIME` accelerated by a double multiplier.

### Field Summary

Fields
`static TimeSource` `CURRENT_TIME` This instance uses `TimeSource.CurrentTimeSource` for generating timestamps.
`static TimeSource` `NANO_TIME` This instance uses `TimeSource.NanoTimeSource` for generating timestamps.

### Constructor Summary

Constructors
Constructor and Description
`TimeSource()`

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`abstract long` `convertDelay(TimeUnit fromUnit, long value, TimeUnit toUnit)`
`static TimeSource` `get(String type)` Obtain an instance of time source.
`abstract long` `getTime()` Return a time value, in nanosecond unit.
`abstract void` `sleep(long ms)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### CURRENT_TIME

    public static final TimeSource CURRENT_TIME

This instance uses `TimeSource.CurrentTimeSource` for generating timestamps.

#### NANO_TIME

    public static final TimeSource NANO_TIME

This instance uses `TimeSource.NanoTimeSource` for generating timestamps.

### Constructor Detail

#### TimeSource

    public TimeSource()

### Method Detail

#### get

    public static TimeSource get(String type)

Obtain an instance of time source.

Parameters:
  `type` - supported types: `currentTime`, `nanoTime` and accelerated time with a double factor in the form of `simTime:FACTOR`, eg. `simTime:2.5`
Returns:
  one of the supported types

#### getTime

    public abstract long getTime()

Return a time value, in nanosecond unit.

#### sleep

    public abstract void sleep(long ms)
                        throws InterruptedException

Throws:
  `InterruptedException`

#### convertDelay

    public abstract long convertDelay(TimeUnit fromUnit,
                                      long value,
                                      TimeUnit toUnit)