Class RsDate

java.lang.Object
java.util.Calendar
java.util.GregorianCalendar
rs.baselib.util.RsDate
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.util.Calendar>
Direct Known Subclasses:
RsDay, RsMonth, RsYear

public class RsDate
extends java.util.GregorianCalendar
A Date replacement object to allow better date computations.
Author:
ralph
See Also:
Serialized Form
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.util.Calendar

    java.util.Calendar.Builder
  • Field Summary

    Fields inherited from class java.util.GregorianCalendar

    AD, BC

    Fields inherited from class java.util.Calendar

    ALL_STYLES, AM, AM_PM, APRIL, areFieldsSet, AUGUST, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DST_OFFSET, ERA, FEBRUARY, FIELD_COUNT, fields, FRIDAY, HOUR, HOUR_OF_DAY, isSet, isTimeSet, JANUARY, JULY, JUNE, LONG, LONG_FORMAT, LONG_STANDALONE, MARCH, MAY, MILLISECOND, MINUTE, MONDAY, MONTH, NARROW_FORMAT, NARROW_STANDALONE, NOVEMBER, OCTOBER, PM, SATURDAY, SECOND, SEPTEMBER, SHORT, SHORT_FORMAT, SHORT_STANDALONE, SUNDAY, THURSDAY, time, TUESDAY, UNDECIMBER, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, YEAR, ZONE_OFFSET
  • Constructor Summary

    Constructors 
    Constructor Description
    RsDate()
    Constructor.
    RsDate​(int year, int month, int dayOfMonth)
    Constructor with default timezone.
    RsDate​(int year, int month, int dayOfMonth, int hourOfDay, int minute)
    Constructor with default timezone.
    RsDate​(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)
    Constructor with default timezone.
    RsDate​(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)
    Constructor with default timezone.
    RsDate​(long timeInMillis)
    Constructor.
    RsDate​(java.util.Calendar calendar)
    Constructor.
    RsDate​(java.util.Date date)
    Constructor.
    RsDate​(java.util.TimeZone timezone)
    Constructor.
    RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth)
    Constructor.
    RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute)
    Constructor.
    RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)
    Constructor.
    RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)
    Constructor.
    RsDate​(java.util.TimeZone timezone, long timeInMillis)
    Constructor.
    RsDate​(java.util.TimeZone timezone, java.util.Date date)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    static RsDate get​(long timestamp)
    Create a date of given timestamp or null.
    static RsDate get​(java.sql.Timestamp timestamp)
    Create a date of given timestamp or null.
    static RsDate get​(java.util.Date date)
    Create a date of given timestamp or null.
    RsDay getDay()
    Returns the day object for this date.
    RsMonth getMonth()
    Returns the month object for this date.
    RsYear getYear()
    Returns the year object for this date.
    java.lang.String toString()

    Methods inherited from class java.util.GregorianCalendar

    add, clone, computeFields, computeTime, equals, from, getActualMaximum, getActualMinimum, getCalendarType, getGreatestMinimum, getGregorianChange, getLeastMaximum, getMaximum, getMinimum, getTimeZone, getWeeksInWeekYear, getWeekYear, hashCode, isLeapYear, isWeekDateSupported, roll, roll, setGregorianChange, setTimeZone, setWeekDate, toZonedDateTime

    Methods inherited from class java.util.Calendar

    after, before, clear, clear, compareTo, complete, get, getAvailableCalendarTypes, getAvailableLocales, getDisplayName, getDisplayNames, getFirstDayOfWeek, getInstance, getInstance, getInstance, getInstance, getMinimalDaysInFirstWeek, getTime, getTimeInMillis, internalGet, isLenient, isSet, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setTime, setTimeInMillis, toInstant

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RsDate

      public RsDate()
      Constructor.
    • RsDate

      public RsDate​(java.util.TimeZone timezone)
      Constructor.
      Parameters:
      timezone - - the timezone for this date
      Since:
      1.2.8
    • RsDate

      public RsDate​(java.util.Date date)
      Constructor.
      Parameters:
      date - - init with this date
    • RsDate

      public RsDate​(java.util.TimeZone timezone, java.util.Date date)
      Constructor.
      Parameters:
      timezone - - the timezone for this date
      date - - init with this date
    • RsDate

      public RsDate​(long timeInMillis)
      Constructor.
      Parameters:
      timeInMillis - - init with this timestamp
    • RsDate

      public RsDate​(java.util.TimeZone timezone, long timeInMillis)
      Constructor.
      Parameters:
      timeInMillis - - init with this timestamp
      timezone - - the timezone for this date
    • RsDate

      public RsDate​(java.util.Calendar calendar)
      Constructor.
      Parameters:
      calendar - - init with calendar time
    • RsDate

      public RsDate​(int year, int month, int dayOfMonth)
      Constructor with default timezone.

      time will be 00:00:00.000.

      Parameters:
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      Since:
      1.2.7
    • RsDate

      public RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth)
      Constructor.

      time will be 00:00:00.000.

      Parameters:
      timezone - the timezone to be used
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      Since:
      1.2.8
    • RsDate

      public RsDate​(int year, int month, int dayOfMonth, int hourOfDay, int minute)
      Constructor with default timezone.

      Calendar.SECONDs and Calendar.MILLISECONDs will be 0.

      Parameters:
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      hourOfDay - hoir of day (0-23)
      minute - minute value (0-59)
      Since:
      1.2.7
    • RsDate

      public RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute)
      Constructor.

      Calendar.SECONDs and Calendar.MILLISECONDs will be 0.

      Parameters:
      timezone - the timezone to be used
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      hourOfDay - hoir of day (0-23)
      minute - minute value (0-59)
      Since:
      1.2.8
    • RsDate

      public RsDate​(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)
      Constructor with default timezone.

      Calendar.MILLISECONDs will be 0.

      Parameters:
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      hourOfDay - hoir of day (0-23)
      minute - minute value (0-59)
      seconds - seconds value(0-59)
      Since:
      1.2.7
    • RsDate

      public RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds)
      Constructor.

      Calendar.MILLISECONDs will be 0.

      Parameters:
      timezone - the timezone to be used
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      hourOfDay - hoir of day (0-23)
      minute - minute value (0-59)
      seconds - seconds value(0-59)
      Since:
      1.2.8
    • RsDate

      public RsDate​(int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)
      Constructor with default timezone.
      Parameters:
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      hourOfDay - hoir of day (0-23)
      minute - minute value (0-59)
      seconds - seconds value(0-59)
      milliseconds - milliseconds value (0-999)
      Since:
      1.2.7
    • RsDate

      public RsDate​(java.util.TimeZone timezone, int year, int month, int dayOfMonth, int hourOfDay, int minute, int seconds, int milliseconds)
      Constructor.
      Parameters:
      timezone - the timezone to be used
      year - year value
      month - month value (0-11)
      dayOfMonth - day of month value (1-31)
      hourOfDay - hoir of day (0-23)
      minute - minute value (0-59)
      seconds - seconds value(0-59)
      milliseconds - milliseconds value (0-999)
      Since:
      1.2.8
  • Method Details

    • getYear

      public RsYear getYear()
      Returns the year object for this date.
      Returns:
      year
    • getMonth

      public RsMonth getMonth()
      Returns the month object for this date.
      Returns:
      month
    • getDay

      public RsDay getDay()
      Returns the day object for this date.
      Returns:
      day
    • get

      public static RsDate get​(java.util.Date date)
      Create a date of given timestamp or null.
      Parameters:
      date - date to be represented
      Returns:
      the RsDate object
    • get

      public static RsDate get​(java.sql.Timestamp timestamp)
      Create a date of given timestamp or null.
      Parameters:
      timestamp - time to be represented
      Returns:
      the RsDate object
    • get

      public static RsDate get​(long timestamp)
      Create a date of given timestamp or null.
      Parameters:
      timestamp - timestamp
      Returns:
      RsDate object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.util.Calendar