1 package net.avcompris.commons3.utils; 2 3 import org.joda.time.DateTime; 4 import org.joda.time.DateTimeZone; 5 import org.springframework.stereotype.Component; 6 7 @Component 8 public final class ClockImpl implements Clock { 9 10 /** 11 * This method uses Joda Time to return the current DateTime, always using UTC 12 * TimeZone. 13 * 14 * @return the current DateTime, with UTC TimeZone 15 */ 16 @Override 17 public DateTime now() { 18 19 return new DateTime().withZone(DateTimeZone.UTC); 20 } 21 22 /** 23 * This method uses Joda Time to return the current UNIX time in milliseconds. 24 * 25 * @return the current UNIX time, in milliseconds 26 */ 27 @Override 28 public long nowMs() { 29 30 return new DateTime().getMillis(); 31 } 32 }