Class DateTime

java.lang.Object
com.easydesk.util.DateTime
All Implemented Interfaces:
Comparable

public class DateTime extends Object implements Comparable
Represents a date/time, or a date without a time. Optionally includes a time zone.
  • Field Details

    • dateTimePattern

      public static final Pattern dateTimePattern
      XML date/time pattern.
    • datePattern

      public static final Pattern datePattern
      XML date pattern.
    • dateTimeChoicePattern

      public static final Pattern dateTimeChoicePattern
      XML date/time or date pattern.
    • value

      protected long value
      Date/time value expressed as the number of ms since the Unix epoch. If the time zone is specified, this value is normalized to UTC, so to format this date/time value, the time zone shift has to be applied.
    • dateOnly

      protected boolean dateOnly
      Specifies whether this is a date-only value.
    • tzShift

      protected Integer tzShift
      DOCUMENT ME!
  • Constructor Details

    • DateTime

      public DateTime()
      Creates a new DateTime object.
    • DateTime

      public DateTime(long value)
      Creates a new DateTime object.
      Parameters:
      value - DOCUMENT ME!
    • DateTime

      public DateTime(Date value)
      Creates a new DateTime object.
      Parameters:
      value - DOCUMENT ME!
    • DateTime

      public DateTime(long value, int tzShift)
      Creates a new DateTime object.
      Parameters:
      value - DOCUMENT ME!
      tzShift - DOCUMENT ME!
    • DateTime

      public DateTime(Date value, TimeZone zone)
      Creates a new DateTime object.
      Parameters:
      value - DOCUMENT ME!
      zone - DOCUMENT ME!
  • Method Details

    • now

      public static DateTime now()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getValue

      public long getValue()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • setValue

      public void setValue(long v)
      DOCUMENT ME!
      Parameters:
      v - DOCUMENT ME!
    • isDateOnly

      public boolean isDateOnly()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • setDateOnly

      public void setDateOnly(boolean v)
      DOCUMENT ME!
      Parameters:
      v - DOCUMENT ME!
    • getTzShift

      public Integer getTzShift()
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • setTzShift

      public void setTzShift(Integer v)
      DOCUMENT ME!
      Parameters:
      v - DOCUMENT ME!
    • hashCode

      public int hashCode()
      DOCUMENT ME!
      Overrides:
      hashCode in class Object
      Returns:
      DOCUMENT ME!
    • equals

      public boolean equals(Object o)
      DOCUMENT ME!
      Overrides:
      equals in class Object
      Parameters:
      o - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • compareTo

      public int compareTo(Object o)
      DOCUMENT ME!
      Specified by:
      compareTo in interface Comparable
      Parameters:
      o - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • toString

      public String toString()
      Formats the value as an xs:date or xs:dateTime string.
      Overrides:
      toString in class Object
    • toString

      public String toString(boolean illegible)
      Formats the value as an xs:date or xs:dateTime string.
    • toStringRfc822

      public String toStringRfc822()
      Formats the value as an RFC 822 date/time.
    • toUiString

      public String toUiString()
      Formats the value as a human-readable string.
    • parseDateTime

      public static DateTime parseDateTime(String str) throws NumberFormatException
      Parses an xs:dateTime string.
      Throws:
      NumberFormatException
    • parseDate

      public static DateTime parseDate(String str) throws NumberFormatException
      Parses an xs:date string.
      Throws:
      NumberFormatException
    • parseDateTimeChoice

      public static DateTime parseDateTimeChoice(String value) throws NumberFormatException
      Parses an XML value that's either an xs:date or xs:dateTime string.
      Throws:
      NumberFormatException - Invalid RFC 3339 date or date/time string.