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

com.yscope.logging.log4j2.ManualTimeSource Maven / Gradle / Ivy

The newest version!
package com.yscope.logging.log4j2;

/**
 * Manual time source that returns the last time that was set. This can be
 * useful to control the current time during unit testing.
 */
public class ManualTimeSource implements TimeSource {
    private long currentTimeInMilliseconds = 0;

    @Override
    public synchronized void setCurrentTimeInMilliseconds(long currentTimeInMilliseconds) {
        this.currentTimeInMilliseconds = currentTimeInMilliseconds;
    }

    @Override
    public synchronized long getCurrentTimeInMilliseconds() { return currentTimeInMilliseconds; }

    public ManualTimeSource(TimeSource timeSource) {
        this.currentTimeInMilliseconds = timeSource.getCurrentTimeInMilliseconds();
    }

    public ManualTimeSource() {
        this.currentTimeInMilliseconds = 0;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy