All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.addc.commons.time.FakeableTimeSource Maven / Gradle / Ivy

Go to download

The addc-base library supplies classes for creating UUIDs, converting between types, outputting byte arrays with different formats, support for Julian dates, delay generators, parsing properties files and support for I18N.

There is a newer version: 2.6
Show newest version
package com.addc.commons.time;

/**
 * The FakeableTimeSource supplies a time source that allows tampering
 */
public class FakeableTimeSource implements TimeSource {
    private long skew;

    @Override
    public long getCurrentTime() {
        return System.currentTimeMillis() + skew;
    }

    /**
     * Add a skew to the current time
     *
     * @param skew
     *            The number of milliseconds to skew the time with
     */
    public void setSkew(long skew) {
        this.skew= skew;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy