Class DateTime

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<DateTime>

    public class DateTime
    extends java.lang.Object
    implements java.lang.Comparable<DateTime>, java.io.Serializable
    Represents date and time information like 2006-01-01 10:00pm independent of the time zone. To convert a date and time object to a point in time (represented in the Java class libraries by Date and Calendar) a time zone has to be provided in the conversion method toDate().
    Author:
    Jan Ortmann
    See Also:
    Date, GregorianCalendar, TimeZone, Serialized Form
    • Constructor Detail

      • DateTime

        public DateTime​(int year,
                        int month,
                        int day)
      • DateTime

        public DateTime​(int year,
                        int month,
                        int day,
                        int hour,
                        int minute,
                        int second)
    • Method Detail

      • parseIso

        public static final DateTime parseIso​(java.lang.String s)
        Parses the given String s to a DateTime object. The string should have the ISO date format (YYYY-MM-DD). Time information is initialized with 0. Returns null if s is null or an empty String.
        Throws:
        java.lang.IllegalArgumentException - if s has a wrong format and can't be parsed.
      • createDateOnly

        public static final DateTime createDateOnly​(java.util.GregorianCalendar calendar)
        Creates a new date time object with the year, month and day information from the GregorianCalendar. Time information is initialized with 0. Returns null if calendar isnull.
      • getDay

        public int getDay()
      • getMonth

        public int getMonth()
      • getYear

        public int getYear()
      • getHour

        public int getHour()
      • getMinute

        public int getMinute()
      • getSecond

        public int getSecond()
      • toTimeInMillisecs

        public long toTimeInMillisecs​(java.util.TimeZone zone)
      • toDate

        public java.util.Date toDate​(java.util.TimeZone zone)
      • toGregorianCalendar

        public java.util.GregorianCalendar toGregorianCalendar​(java.util.TimeZone zone)
      • toIsoFormat

        public java.lang.String toIsoFormat()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • compareTo

        public int compareTo​(DateTime other)
        Specified by:
        compareTo in interface java.lang.Comparable<DateTime>