home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.6 KB | 69 lines |
- // Date.java
- // 24.03.96
- //
- // for demonstration and testing purposes, it helps to be able to
- // use a date other than the actual, current one. This class allows
- // us to set a new current date
-
- package cybcerone.utils;
-
- /**
- * Our own little date class, so that we can set the current date
- * for demonstrations.
- */
- public class Date extends java.util.Date {
- private static java.util.Date currentDate = new java.util.Date ();
- private static java.util.Date current =
- new java.util.Date (currentDate.getYear (),
- currentDate.getMonth (),
- currentDate.getDate ());
-
- private static boolean real = true;
-
- public Date () {
- super (current.getTime ());
- java.util.Date temp = new java.util.Date ();
- setHours (temp.getHours ());
- setMinutes (temp.getMinutes ());
- setSeconds (temp.getSeconds ());
- }
-
- public Date (int year, int month, int date) {
- super (year, month, date);
- }
-
- public Date (int year, int month, int date, int hrs, int min) {
- super (year, month, date, hrs, min);
- }
-
- public Date (int year, int month, int date, int hrs, int min, int sec) {
- super (year, month, date, hrs, min, sec);
- }
-
- public Date (String s) {
- super (s);
- }
-
- /** Set today's date. */
- public static void setCurrent (int year, int month, int day) {
- current = new java.util.Date (year - 1900, month - 1, day);
- real = false;
- }
-
- /** Returns true the current date has been set, otherwise false */
- public static boolean realDate () {
- return real;
- }
-
- /** Redefine midnight to be 24 */
- public int getHours () {
- int hours = super.getHours ();
-
- if (hours == 0)
- return 24;
- else
- return hours;
- }
-
- }
-