Package org.ocpsoft.prettytime
Interface TimeUnit
- All Known Implementing Classes:
Century,Day,Decade,Hour,JustNow,Millennium,Millisecond,Minute,Month,ResourcesTimeUnit,Second,Week,Year
public interface TimeUnit
Defines a Unit of time (e.g. seconds, minutes, hours) and its conversion to milliseconds.
- Author:
- Lincoln Baxter, III
-
Method Summary
Modifier and TypeMethodDescriptionlongThe maximum quantity of this Unit to be used as a threshold for the next largest Unit (e.g.longThe number of milliseconds represented by each instance of this TimeUnit.booleanWhether or not thisTimeUnitrepresents a price measurement of time, or a general concept of time.
-
Method Details
-
getMillisPerUnit
long getMillisPerUnit()The number of milliseconds represented by each instance of this TimeUnit. Must be a positive number greater than zero. -
getMaxQuantity
long getMaxQuantity()The maximum quantity of this Unit to be used as a threshold for the next largest Unit (e.g. if oneSecondrepresents 1000ms, andSecondhas a maxQuantity of 5, then if the difference between compared timestamps is larger than 5000ms, PrettyTime will move on to the next smallest TimeUnit for calculation;Minute, by default)millisPerUnit * maxQuantity = maxAllowedMs
If maxQuantity is zero, it will be equal to the next highest
TimeUnit.getMillisPerUnit() / this.getMillisPerUnit()or infinity if there are no greater TimeUnits -
isPrecise
boolean isPrecise()Whether or not thisTimeUnitrepresents a price measurement of time, or a general concept of time. E.g: "minute" as opposed to "moment".
-