package com.atlassian.stash.internal.config;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;

/**
 * A clock that constructs a date-time instance set to the current system millisecond
 * time using ISOChronology in the default time zone.
 */
@Component
public class SystemClock implements Clock {

    @Override
    public long nanoTime() {
        return System.nanoTime();
    }

    @Override
    @Nonnull
    public DateTime now() {
        return new DateTime();
    }

    @Override
    public long utcMillis() {
        return DateTime.now(DateTimeZone.UTC).getMillis();
    }
}
