You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2013/05/06 17:40:52 UTC
[3/3] git commit: ISIS-398: extend Clock interface for Joda...
ISIS-398: extend Clock interface for Joda...
... to return Joda's LocalDate or LocalDateTime
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/e5e5a728
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/e5e5a728
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/e5e5a728
Branch: refs/heads/master
Commit: e5e5a72867c5a6fb20f6eb008fcf4423afeca68a
Parents: ef20bea
Author: Dan Haywood <da...@apache.org>
Authored: Mon May 6 16:28:35 2013 +0100
Committer: Dan Haywood <da...@apache.org>
Committed: Mon May 6 16:28:35 2013 +0100
----------------------------------------------------------------------
.../java/org/apache/isis/applib/clock/Clock.java | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/e5e5a728/core/applib/src/main/java/org/apache/isis/applib/clock/Clock.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/clock/Clock.java b/core/applib/src/main/java/org/apache/isis/applib/clock/Clock.java
index 19a880a..6aaad8d 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/clock/Clock.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/clock/Clock.java
@@ -23,6 +23,8 @@ import java.util.Calendar;
import java.util.Date;
import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
+import org.joda.time.LocalDateTime;
import org.apache.isis.applib.ApplicationException;
import org.apache.isis.applib.Defaults;
@@ -104,6 +106,19 @@ public abstract class Clock {
return new Date(getTime());
}
+ public static LocalDate getTimeAsLocalDate() {
+ return new LocalDate(getTime(), Defaults.getTimeZone());
+ }
+
+ public static LocalDateTime getTimeAsLocalDateTime() {
+ return new LocalDateTime(getTime(), Defaults.getTimeZone());
+ }
+
+ /**
+ * Returns the {@link #getTime() time} as a Joda {@link DateTime},
+ * using the {@link Defaults#getTimeZone() timezone} as
+ * {@link Defaults#setTimeZone(org.joda.time.DateTimeZone) currently set}.
+ */
public static DateTime getTimeAsDateTime() {
return new DateTime(getTime(), Defaults.getTimeZone());
}