Class DateTime

  • All Implemented Interfaces:
    Renderable, java.io.Serializable, java.lang.Comparable<DateTime>, scala.Equals, scala.math.Ordered<DateTime>, scala.Product

    public final class DateTime
    extends DateTime
    implements scala.math.Ordered<DateTime>, Renderable, scala.Product, java.io.Serializable
    Immutable, fast and efficient Date + Time implementation without any dependencies. Does not support TimeZones, all DateTime values are always GMT based. Note that this implementation discards milliseconds (i.e. rounds down to full seconds).
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DateTime()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static DateTime apply​(int year, int month, int day, int hour, int minute, int second)
      Creates a new DateTime with the given properties.
      static DateTime apply​(long clicks)
      Creates a new DateTime from the number of milli seconds since the start of "the epoch", namely January 1, 1970, 00:00:00 GMT.
      long clicks()
      Returns this instant as "clicks", i.e. as milliseconds since January 1, 1970, 00:00:00 GMT
      int compare​(DateTime that)  
      int day()
      Returns the day of this instant in GMT.
      boolean equals​(java.lang.Object obj)  
      static scala.Option<DateTime> fromIsoDateTimeString​(java.lang.String string)
      Creates a new DateTime instance from the given String, if it adheres to the format yyyy-mm-ddThh:mm:ss[.SSSZ].
      int hashCode()  
      int hour()
      Returns the hour of this instant in GMT.
      boolean isLeapYear()
      Returns if this instant interpreted as a Date in GMT belongs to a leap year.
      static DateTime MaxValue()  
      DateTime minus​(long millis)
      Creates a new DateTime that represents the point in time the given number of ms earlier.
      int minute()
      Returns the minute of this instant in GMT.
      static DateTime MinValue()  
      int month()
      Returns the month of this instant in GMT.
      java.lang.String monthStr()
      The month as a 3 letter abbreviation: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov or Dec
      static DateTime now()
      Creates a new DateTime instance for the current point in time.
      DateTime plus​(long millis)
      Creates a new DateTime that represents the point in time the given number of ms later.
      <R extends Rendering>
      Rendering
      render​(R r)
      yyyy-mm-ddThh:mm:ss
      <R extends Rendering>
      Rendering
      renderIsoDate​(R r)
      yyyy-mm-dd
      <R extends Rendering>
      Rendering
      renderIsoDateTimeString​(R r)
      yyyy-mm-ddThh:mm:ss
      <R extends Rendering>
      Rendering
      renderIsoLikeDateTimeString​(R r)
      yyyy-mm-dd hh:mm:ss
      <R extends Rendering>
      Rendering
      renderRfc1123DateTimeString​(R r)
      RFC1123 date string, e.g.
      int second()
      Returns the second of this instant in GMT.
      java.lang.String toIsoDateString()
      yyyy-mm-dd
      java.lang.String toIsoDateTimeString()
      yyyy-mm-ddThh:mm:ss
      java.lang.String toIsoLikeDateTimeString()
      yyyy-mm-dd hh:mm:ss
      java.lang.String toRfc1123DateTimeString()
      RFC1123 date string, e.g.
      java.lang.String toString()
      yyyy-mm-ddThh:mm:ss
      int weekday()
      Returns the weekday of this instant in GMT.
      java.lang.String weekdayStr()
      The day of the week as a 3 letter abbreviation: Sun, Mon, Tue, Wed, Thu, Fri or Sat
      int year()
      Returns the year of this instant in GMT.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface scala.Equals

        canEqual
      • Methods inherited from interface scala.math.Ordered

        $greater, $greater$eq, $less, $less$eq, compareTo
      • Methods inherited from interface scala.Product

        productArity, productElement, productElementName, productElementNames, productIterator, productPrefix
    • Constructor Detail

      • DateTime

        public DateTime()
    • Method Detail

      • MinValue

        public static DateTime MinValue()
      • MaxValue

        public static DateTime MaxValue()
      • apply

        public static DateTime apply​(int year,
                                     int month,
                                     int day,
                                     int hour,
                                     int minute,
                                     int second)
        Creates a new DateTime with the given properties. Note that this implementation discards milliseconds (i.e. rounds down to full seconds).
        Parameters:
        year - (undocumented)
        month - (undocumented)
        day - (undocumented)
        hour - (undocumented)
        minute - (undocumented)
        second - (undocumented)
        Returns:
        (undocumented)
      • apply

        public static DateTime apply​(long clicks)
        Creates a new DateTime from the number of milli seconds since the start of "the epoch", namely January 1, 1970, 00:00:00 GMT. Note that this implementation discards milliseconds (i.e. rounds down to full seconds).
        Parameters:
        clicks - (undocumented)
        Returns:
        (undocumented)
      • now

        public static DateTime now()
        Creates a new DateTime instance for the current point in time. Note that this implementation discards milliseconds (i.e. rounds down to full seconds).
        Returns:
        (undocumented)
      • fromIsoDateTimeString

        public static scala.Option<DateTime> fromIsoDateTimeString​(java.lang.String string)
        Creates a new DateTime instance from the given String, if it adheres to the format yyyy-mm-ddThh:mm:ss[.SSSZ]. Note that this implementation discards milliseconds (i.e. rounds down to full seconds).
        Parameters:
        string - (undocumented)
        Returns:
        (undocumented)
      • year

        public int year()
        Description copied from class: DateTime
        Returns the year of this instant in GMT.
        Specified by:
        year in class DateTime
      • month

        public int month()
        Description copied from class: DateTime
        Returns the month of this instant in GMT.
        Specified by:
        month in class DateTime
      • day

        public int day()
        Description copied from class: DateTime
        Returns the day of this instant in GMT.
        Specified by:
        day in class DateTime
      • hour

        public int hour()
        Description copied from class: DateTime
        Returns the hour of this instant in GMT.
        Specified by:
        hour in class DateTime
      • minute

        public int minute()
        Description copied from class: DateTime
        Returns the minute of this instant in GMT.
        Specified by:
        minute in class DateTime
      • second

        public int second()
        Description copied from class: DateTime
        Returns the second of this instant in GMT.
        Specified by:
        second in class DateTime
      • weekday

        public int weekday()
        Description copied from class: DateTime
        Returns the weekday of this instant in GMT. Sunday is 0, Monday is 1, etc.
        Specified by:
        weekday in class DateTime
      • clicks

        public long clicks()
        Description copied from class: DateTime
        Returns this instant as "clicks", i.e. as milliseconds since January 1, 1970, 00:00:00 GMT
        Specified by:
        clicks in class DateTime
      • isLeapYear

        public boolean isLeapYear()
        Description copied from class: DateTime
        Returns if this instant interpreted as a Date in GMT belongs to a leap year.
        Specified by:
        isLeapYear in class DateTime
      • weekdayStr

        public java.lang.String weekdayStr()
        The day of the week as a 3 letter abbreviation: Sun, Mon, Tue, Wed, Thu, Fri or Sat
        Specified by:
        weekdayStr in class DateTime
        Returns:
        (undocumented)
      • monthStr

        public java.lang.String monthStr()
        The month as a 3 letter abbreviation: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov or Dec
        Specified by:
        monthStr in class DateTime
        Returns:
        (undocumented)
      • minus

        public DateTime minus​(long millis)
        Creates a new DateTime that represents the point in time the given number of ms earlier.
        Specified by:
        minus in class DateTime
        Parameters:
        millis - (undocumented)
        Returns:
        (undocumented)
      • plus

        public DateTime plus​(long millis)
        Creates a new DateTime that represents the point in time the given number of ms later.
        Specified by:
        plus in class DateTime
        Parameters:
        millis - (undocumented)
        Returns:
        (undocumented)
      • render

        public <R extends RenderingRendering render​(R r)
        yyyy-mm-ddThh:mm:ss
        Specified by:
        render in interface Renderable
        Parameters:
        r - (undocumented)
        Returns:
        (undocumented)
      • toString

        public java.lang.String toString()
        yyyy-mm-ddThh:mm:ss
        Overrides:
        toString in class java.lang.Object
        Returns:
        (undocumented)
      • renderIsoDate

        public <R extends RenderingRendering renderIsoDate​(R r)
        yyyy-mm-dd
        Parameters:
        r - (undocumented)
        Returns:
        (undocumented)
      • toIsoDateString

        public java.lang.String toIsoDateString()
        yyyy-mm-dd
        Specified by:
        toIsoDateString in class DateTime
        Returns:
        (undocumented)
      • renderIsoDateTimeString

        public <R extends RenderingRendering renderIsoDateTimeString​(R r)
        yyyy-mm-ddThh:mm:ss
        Parameters:
        r - (undocumented)
        Returns:
        (undocumented)
      • toIsoDateTimeString

        public java.lang.String toIsoDateTimeString()
        yyyy-mm-ddThh:mm:ss
        Specified by:
        toIsoDateTimeString in class DateTime
        Returns:
        (undocumented)
      • renderIsoLikeDateTimeString

        public <R extends RenderingRendering renderIsoLikeDateTimeString​(R r)
        yyyy-mm-dd hh:mm:ss
        Parameters:
        r - (undocumented)
        Returns:
        (undocumented)
      • toIsoLikeDateTimeString

        public java.lang.String toIsoLikeDateTimeString()
        yyyy-mm-dd hh:mm:ss
        Specified by:
        toIsoLikeDateTimeString in class DateTime
        Returns:
        (undocumented)
      • renderRfc1123DateTimeString

        public <R extends RenderingRendering renderRfc1123DateTimeString​(R r)
        RFC1123 date string, e.g. Sun, 06 Nov 1994 08:49:37 GMT
        Parameters:
        r - (undocumented)
        Returns:
        (undocumented)
      • toRfc1123DateTimeString

        public java.lang.String toRfc1123DateTimeString()
        RFC1123 date string, e.g. Sun, 06 Nov 1994 08:49:37 GMT
        Specified by:
        toRfc1123DateTimeString in class DateTime
        Returns:
        (undocumented)
      • compare

        public int compare​(DateTime that)
        Specified by:
        compare in interface scala.math.Ordered<DateTime>
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface scala.Equals
        Overrides:
        equals in class java.lang.Object