1 package org.cacert.gigi.util;
6 * This Class consists of a millisecond timestamp that is only interesting up to
11 public static final long MILLI_DAY = 24 * 60 * 60 * 1000;
16 * Creates a new {@link DayDate} from the SQL Day-exact variant {@link Date}
21 public DayDate(Date date) {
26 * Creates a new {@link DayDate} based on the given millisecond timestamp.
29 * the timestamp to create the Date from.
30 * @throws IllegalArgumentException
31 * if the parameter contains more precision than needed.
33 public DayDate(long millis) {
35 if (millis % MILLI_DAY != 0) {
36 throw new IllegalArgumentException();
41 * Gets the enclosed timestamp.
43 * @return the enclosed timestamp.
45 public long getTime() {
50 * Converts this DayDate to an {@link Date}.
52 * @return the corresponding {@link Date}
55 public Date toSQLDate() {
56 return new Date(time);
60 public boolean equals(Object obj) {
64 if ( !(obj instanceof DayDate)) {
65 throw new Error("You may not compare this date somthing other than a DayDate");
67 return ((DayDate) obj).time == time;
71 public int hashCode() {
72 return Long.hashCode(time);
75 public java.util.Date toDate() {
76 return new java.util.Date(time);