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

net.serenitybdd.core.time.InternalSystemClock Maven / Gradle / Ivy

There is a newer version: 4.2.1
Show newest version
package net.serenitybdd.core.time;

import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Object that encapsulates system clock operations.
 */
public class InternalSystemClock implements SystemClock {

    private static final Logger LOGGER = LoggerFactory.getLogger(InternalSystemClock.class);

    /**
     * Pause execution for the requested delay.
     * Throws a runtime exception if something goes wrong.
     */
    public void pauseFor(final long timeInMilliseconds) {

         try {
             sleepFor(timeInMilliseconds);
         } catch (InterruptedException e) {
             LOGGER.error("Wait interrupted:" +  e.getMessage());
             throw new RuntimeException("System timer interrupted", e);
         }
    }

    protected void sleepFor(long timeInMilliseconds) throws InterruptedException {
        Thread.sleep(timeInMilliseconds);
    }

    /**
     * Find the current system time.
     */
    public DateTime getCurrentTime() {
        return new DateTime();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy