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;h=a6135697b71d38e99807f826d7479284a717d847;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(); + } + +}