Class Date

  • All Implemented Interfaces:
    Comparable<Date>

    public final class Date
    extends Object
    implements Comparable<Date>
    Instance of this class represents date-time value containing year, month, day of month, hour, minute and second
    • Constructor Detail

      • Date

        public Date​(int year,
                    int month,
                    int day,
                    int hour,
                    int minute,
                    int second)
        Constructor
        Parameters:
        year - must be 1..9999.
        month - must be 1..12
        day - must be 1..depends on month
        hour - must be 0..23
        minute - must be 0..59
        second - must be 0..59
      • Date

        public Date​(int year,
                    int month,
                    int day)
        Constructor. Constructs instance containing only date without time. Hour, minute and second are set to 0.
        Parameters:
        year - must be 1..9999.
        month - must be 1..12
        day - must be 1..depends on month
    • Method Detail

      • fromString

        public static Date fromString​(String str)
        Creates Date instance from string. String should be presented as "YYYY-MM-DDTHH:MM:SS" or "YYYY-MM-DD"
        Parameters:
        str - string containing date-time.
        Returns:
        created Date instance
      • fromJavaDate

        public static Date fromJavaDate​(Date date)
        Creates date from Date
        Parameters:
        date - Date value, must not be null
        Returns:
        Date value
      • toJavaDate

        public static Date toJavaDate​(Date date)
        Creates Date from date
        Parameters:
        date - Date value, must not be null
        Returns:
        Date value
      • getCurrentDate

        public static Date getCurrentDate()
        Returns current date
        Returns:
        Date value
      • getYear

        public int getYear()
        Returns:
        year value
      • getMonth

        public int getMonth()
        Returns:
        month value
      • getDay

        public int getDay()
        Returns:
        day value
      • getHour

        public int getHour()
        Returns:
        hour value
      • getMinute

        public int getMinute()
        Returns:
        minute value
      • getSecond

        public int getSecond()
        Returns:
        second value
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object