From: erik Date: Sun, 24 Jul 2011 18:58:25 +0000 (+0000) Subject: UTILS-14: Add clock abstraction. X-Git-Tag: BEFORE_SVN_TO_GIT~3 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=a6135697b71d38e99807f826d7479284a717d847;hp=ce3af724d5eab3e1a7515d1c0e9118960c6b7ffb;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(); + } + +}