Class ComparisonDateTool.Comparison

  • Enclosing class:
    ComparisonDateTool

    public class ComparisonDateTool.Comparison
    extends java.lang.Object
    • Field Detail

      • milliseconds

        private final long milliseconds
      • type

        private final int type
      • maxUnitDepth

        private final int maxUnitDepth
      • abbreviate

        private final boolean abbreviate
      • locale

        private final java.util.Locale locale
    • Constructor Detail

      • Comparison

        public Comparison​(long ms,
                          int type,
                          int depth,
                          boolean abbr,
                          java.util.Locale loc)
    • Method Detail

      • abbr

        public ComparisonDateTool.Comparison abbr​(boolean abbr)
        Sets whether or not this comparison is to be rendered in abbreviated form or not. By default, it is not abbreviated.
      • depth

        public ComparisonDateTool.Comparison depth​(int depth)
        Set the maximum number of units to render for this comparison. By default, this is set to 1 unit.
      • locale

        public ComparisonDateTool.Comparison locale​(java.util.Locale loc)
        Sets the locale used to look up the textual portions of the rendering. This defaults to the Locale configured for this tool, if any. If no locale was configured, this defaults to the system default.
      • getYears

        public long getYears()
        Return the approximate number of years between the dates being compared.
      • getMonths

        public long getMonths()
        Return the approximate number of months between the dates being compared.
      • getWeeks

        public long getWeeks()
        Return the number of weeks between the dates being compared.
      • getDays

        public long getDays()
        Return the number of days between the dates being compared.
      • getHours

        public long getHours()
        Return the number of hours between the dates being compared.
      • getMinutes

        public long getMinutes()
        Return the number of minutes between the dates being compared.
      • getSeconds

        public long getSeconds()
        Return the number of seconds between the dates being compared.
      • getMilliseconds

        public long getMilliseconds()
        Return the number of milliseconds between the dates being compared.
      • getFull

        public ComparisonDateTool.Comparison getFull()
        Sets the depth(int depth) to which this comparison is rendered to the maximum number of time units available to the tool. By default, there are 8 units available, but the tool may be configured to "skip" any of the standard units, thus shortening the maximum depth.
      • toString

        public java.lang.String toString()
        Renders this comparison to a String.
        Overrides:
        toString in class java.lang.Object