Class TimeUnit


  • public final class TimeUnit
    extends Object
    'Enum' for individual time units. Not an actual enum so that it can be used by Java 1.4.
    • Field Detail

      • YEAR

        public static final TimeUnit YEAR
        Represents a year.
      • MONTH

        public static final TimeUnit MONTH
        Represents a month.
      • WEEK

        public static final TimeUnit WEEK
        Represents a week.
      • DAY

        public static final TimeUnit DAY
        Represents a day.
      • HOUR

        public static final TimeUnit HOUR
        Represents an hour.
      • MINUTE

        public static final TimeUnit MINUTE
        Represents a minute.
      • SECOND

        public static final TimeUnit SECOND
        Represents a second.
      • MILLISECOND

        public static final TimeUnit MILLISECOND
        Represents a millisecond.
    • Method Detail

      • toString

        public String toString()
        Description copied from class: Object
        Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
           getClass().getName() + '@' + Integer.toHexString(hashCode())

        See Writing a useful toString method if you intend implementing your own toString method.

        Overrides:
        toString in class Object
        Returns:
        a printable representation of this object.
      • larger

        public TimeUnit larger()
        Returns the next larger time unit, or null if this is the largest.
      • smaller

        public TimeUnit smaller()
        Returns the next smaller time unit, or null if this is the smallest.
      • ordinal

        public int ordinal()
        Returns the ordinal value of this time unit, largest is 0.