]> WPIA git - gigi.git/blobdiff - src/club/wpia/gigi/util/DayDate.java
fix: correct validation of minimum and maximum ages
[gigi.git] / src / club / wpia / gigi / util / DayDate.java
index 8ade34270b444839aa9549f72e746ce17d54460d..85473eccdf1b7999e51542be10655b84ced0d648 100644 (file)
@@ -8,7 +8,9 @@ import java.sql.Date;
  */
 public class DayDate {
 
-    public static final long MILLI_DAY = 24 * 60 * 60 * 1000;
+    private static final int MILLI_HOUR = 60 * 60 * 1000;
+
+    public static final long MILLI_DAY = 24 * MILLI_HOUR;
 
     private long time;
 
@@ -75,4 +77,24 @@ public class DayDate {
     public java.util.Date toDate() {
         return new java.util.Date(time);
     }
+
+    // Timezones currently reach from UTC-12 to UTC+14 that allows us to define
+    // the "earliest start" and "latest end" of a Date.
+    /**
+     * Gets this date's starting point.
+     * 
+     * @return The earliest point in time where this date was in any timezone
+     */
+    public java.util.Date start() {
+        return new java.util.Date(time - 12 * MILLI_HOUR);
+    }
+
+    /**
+     * Gets this date's ending point.
+     * 
+     * @return The latest point in time where this Date was any timezone
+     */
+    public java.util.Date end() {
+        return new java.util.Date(time + 14 * MILLI_HOUR + 24 * MILLI_HOUR);
+    }
 }