/** * Sets the time value of this <tt>Date</tt> directly * * @param time the new time value for this <tt>Date</tt> */ public void setTime(long time) { getCalendar(true).setTimeInMillis(time); }
/** * Returns the time value associated to this <tt>Date</tt> * * @return the time value associated to this <tt>Date</tt> */ public double getTime() { if (getCalendar(false) != null) { return calendar.getTimeInMillis(); } return Double.NaN; }
/** * Returns the difference between local time and UTC time in minutes. * * @return the difference between local time and UTC time in minutes. */ public double getTimezoneOffset() { // in minutes if (getCalendar(false) != null) { return -calendar.getTimeZone().getRawOffset() / 1000 / 60; } return Double.NaN; }
/** * Returns a <tt>String</tt> representation of the "time" portion of this * <tt>Date</tt> (ie: without date) in the current time zone. The contents * of the <tt>String</tt> are implementation-dependent, but are intended to * be in a convenient, human-readable form. * * @return a human readable version of the "time" portion of this <tt>Date</tt>, in the local time zone */ public String toTimeString() { if (getCalendar(false) != null) { return DateFormat.getTimeInstance(DateFormat.FULL, Locale.US).format(calendar.getTime()); } return null; }
/** * Returns a <tt>String</tt> representation of the "date" portion of this * <tt>Date</tt> (ie: without time) in the current time zone. The contents * of the String are implementation-dependent, but are intended to be in a * convenient, human-readable form. * * @return a human readable version of the "date" portion of this <tt>Date</tt>, in the local time zone */ public String toDateString(){ if (getCalendar(false) != null) { return DateFormat.getDateInstance(DateFormat.FULL, Locale.US).format(calendar.getTime()); } return null; }
/** * Returns the minutes of the hour corresponding to this <tt>Date</tt>'s time * value, in the local time zone. * * @return the minutes of the hour corresponding to this <tt>Date</tt>'s time value, in the local time zone. */ public double getMinutes() { return getField(getCalendar(false), Calendar.MINUTE); }
/** * Returns the day of the month corresponding to this <tt>Date</tt>'s time value, * in the local time zone. * * @return the day of the month corresponding to this <tt>Date</tt>'s time value, in the local time zone. */ public double getDate() { return getField(getCalendar(false), Calendar.DAY_OF_MONTH); }
/** * Returns the hour of the day corresponding to this <tt>Date</tt>'s time * value, in the local time zone. * * @return the hour of the day corresponding to this <tt>Date</tt>'s time value, in the local time zone. */ public double getHours() { return getField(getCalendar(false), Calendar.HOUR_OF_DAY); }
/** * Returns the day of the week corresponding to this <tt>Date</tt>'s time * value, in the local time zone. A weekday value of 0 specifies Sunday; 1 * specifies Monday; 2 specifies Tuesday; 3 specifies Wednesday; 4 * specifies Thursday; 5 specifies Friday; and 6 specifies Saturday * * @return the day of the week corresponding to this <tt>Date</tt>'s time value, in the local time zone. */ public double getDay() { return getField(getCalendar(false), Calendar.DAY_OF_WEEK); }
/** * Returns the year corresponding to this <tt>Date</tt>'s time value, in * the local time zone. * * @return the year corresponding to this <tt>Date</tt>'s time value, in the local time zone. */ public double getFullYear() { return getField(getCalendar(false), Calendar.YEAR); }
/** * Returns the month number corresponding to this <tt>Date</tt>'s time value, * in the local time zone. Month numbers are 0 indexed, with January being 0 * and December being 11. * * @return Returns the month number in which this <tt>Date</tt> is placed, in the local time zone */ public double getMonth() { return getField(getCalendar(false), Calendar.MONTH); }
/** * Returns the milliseconds of the second corresponding to this <tt>Date</tt>'s time * value, in the local time zone. * * @return the milliseconds of the second corresponding to this <tt>Date</tt>'s time value, in the local time zone. */ public double getMilliseconds() { return getField(getCalendar(false), Calendar.MILLISECOND); }
/** * Returns the seconds of the minute corresponding to this <tt>Date</tt>'s time * value, in the local time zone. * * @return the seconds of the minute corresponding to this <tt>Date</tt>'s time value, in the local time zone. */ public double getSeconds() { return getField(getCalendar(false), Calendar.SECOND); }
/** * Sets the day of month field of this <tt>Date</tt> interpreted in the * local time zone. * * @param day the new day of month */ public void setDate(int day) { setField(getCalendar(true), Calendar.DAY_OF_WEEK, day); }
/** * Sets the milliseconds field of this <tt>Date</tt> interpreted in the local time zone. * * @param ms the new milliseconds */ public void setMilliseconds(int ms) { setField(getCalendar(true), Calendar.MILLISECOND, ms); }
/** * Sets the seconds and milliseconds fields of this <tt>Date</tt> * interpreted in the local time zone. * * @param sec the new seconds * @param ms the new milliseconds */ public void setSeconds(int sec, int ms) { setField(getCalendar(true), Calendar.SECOND, sec); setMilliseconds(ms); }
/** * Sets the month of year and day of month fields of this <tt>Date</tt> * interpreted in the local time zone. Month numbers are 0 indexed, with * January being 0 and December being 11. * * @param month the new month * @param day the new day of month */ public void setMonth(int month, int day) { setField(getCalendar(true), Calendar.MONTH, month); setDate(day); }
/** * Sets the minutes, seconds and milliseconds field of this <tt>Date</tt> * interpreted in the local time zone. * * @param min the new minutes * @param sec the new seconds * @param ms the new milliseconds */ public void setMinutes(int min, int sec, int ms) { setField(getCalendar(true), Calendar.MINUTE, min); setSeconds(sec, ms); }
/** * Sets the year, month and day of month fields of this <tt>Date</tt> * interpreted in the local time zone. * * @param year the new year * @param month the new month * @param day the new day of month */ public void setFullYear(int year, int month, int day) { setField(getCalendar(true), Calendar.YEAR, year); setMonth(month, day); }
/** * Sets the hours, minutes, seconds and milliseconds field of this * <tt>Date</tt> interpreted in the local time zone. * * @param hour the new hour * @param min the new minutes * @param sec the new seconds * @param ms the new milliseconds */ public void setHours(int hour, int min, int sec, int ms) { setField(getCalendar(true), Calendar.HOUR_OF_DAY, hour); setMinutes(min, sec, ms); }