From: Erik Brakkee Date: Sun, 24 Jul 2011 18:58:25 +0000 (+0000) Subject: UTILS-14: Add clock abstraction. X-Git-Tag: wamblee-utils-0.7~13 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=7a50a63b1ae202af13f0475cc8a9d3cd93d3c41f;p=utils UTILS-14: Add clock abstraction. --- diff --git a/support/general/src/main/java/org/wamblee/general/Clock.java b/support/general/src/main/java/org/wamblee/general/Clock.java new file mode 100644 index 00000000..e5510eda --- /dev/null +++ b/support/general/src/main/java/org/wamblee/general/Clock.java @@ -0,0 +1,29 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wamblee.general; + +/** + * Clock abstraction for {@link System#currentTimeMillis()}. + * + * @author Erik Brakkee + */ +public interface Clock { + + /** + * @return Current time. + */ + long currentTimeMillis(); +} diff --git a/support/general/src/main/java/org/wamblee/general/SystemClock.java b/support/general/src/main/java/org/wamblee/general/SystemClock.java new file mode 100644 index 00000000..1295258c --- /dev/null +++ b/support/general/src/main/java/org/wamblee/general/SystemClock.java @@ -0,0 +1,30 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wamblee.general; + +/** + * Default clock implementation delegating to the system clock. + * + * @author Erik Brakkee + */ +public class SystemClock implements Clock { + + @Override + public long currentTimeMillis() { + return System.currentTimeMillis(); + } + +}