Class DateString

  • All Implemented Interfaces:

    public class DateString
    extends java.lang.Object
    implements java.lang.Comparable<DateString>
    Date literal.

    Immutable, internally represented as a string (in ISO format).

    • Field Summary

      Modifier and Type Field Description
      private static java.util.regex.Pattern PATTERN  
      (package private) java.lang.String v  
    • Constructor Summary

      Modifier Constructor Description
        DateString​(int year, int month, int day)
      Creates a DateString for year, month, day values.
        DateString​(java.lang.String v)
      Creates a DateString.
      private DateString​(java.lang.String v, boolean ignore)
      Internal constructor, no validation.
    • Field Detail

      • PATTERN

        private static final java.util.regex.Pattern PATTERN
      • v

        final java.lang.String v
    • Constructor Detail

      • DateString

        private DateString​(java.lang.String v,
                           boolean ignore)
        Internal constructor, no validation.
      • DateString

        public DateString​(java.lang.String v)
        Creates a DateString.
      • DateString

        public DateString​(int year,
                          int month,
                          int day)
        Creates a DateString for year, month, day values.
    • Method Detail

      • ymd

        private static java.lang.String ymd​(int year,
                                            int month,
                                            int day)
        Validates a year-month-date and converts to a string.
      • toString

        public java.lang.String toString()
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(@Nonnull
                             DateString o)
        Specified by:
        compareTo in interface java.lang.Comparable<DateString>
      • fromCalendarFields

        public static DateString fromCalendarFields​(java.util.Calendar calendar)
        Creates a DateString from a Calendar.
      • getDaysSinceEpoch

        public int getDaysSinceEpoch()
        Returns the number of days since the epoch.
      • getYear

        private int getYear()
      • getMonth

        private int getMonth()
      • getDay

        private int getDay()
      • fromDaysSinceEpoch

        public static DateString fromDaysSinceEpoch​(int days)
        Creates a DateString that is a given number of days since the epoch.
      • getMillisSinceEpoch

        public long getMillisSinceEpoch()
        Returns the number of milliseconds since the epoch. Always a multiple of 86,400,000 (the number of milliseconds in a day).
      • toCalendar

        public java.util.Calendar toCalendar()