Class TimeUnit


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

      Fields 
      Modifier and Type Field Description
      (package private) static long[] approxDurations
      Approximate, durations for the units independent of the time at which they are measured
      static TimeUnit DAY
      Represents a day.
      static TimeUnit HOUR
      Represents an hour.
      static TimeUnit MILLISECOND
      Represents a millisecond.
      static TimeUnit MINUTE
      Represents a minute.
      static TimeUnit MONTH
      Represents a month.
      (package private) java.lang.String name
      The name of this unit, a key, not for localization.
      (package private) byte ordinal
      The ordinal of the unit, in order from largest to smallest.
      static TimeUnit SECOND
      Represents a second.
      (package private) static TimeUnit[] units
      The list of units, in order from largest to smallest.
      static TimeUnit WEEK
      Represents a week.
      static TimeUnit YEAR
      Represents a year.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private TimeUnit​(java.lang.String name, int ordinal)
      Private constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TimeUnit larger()
      Returns the next larger time unit, or null if this is the largest.
      int ordinal()
      Returns the ordinal value of this time unit, largest is 0.
      TimeUnit smaller()
      Returns the next smaller time unit, or null if this is the smallest.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • name

        final java.lang.String name
        The name of this unit, a key, not for localization.
      • ordinal

        final byte ordinal
        The ordinal of the unit, in order from largest to smallest.
      • 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.
      • units

        static final TimeUnit[] units
        The list of units, in order from largest to smallest.
      • approxDurations

        static final long[] approxDurations
        Approximate, durations for the units independent of the time at which they are measured
    • Constructor Detail

      • TimeUnit

        private TimeUnit​(java.lang.String name,
                         int ordinal)
        Private constructor
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.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.