- java.lang.Object
-
- com.aoapps.lang.time.Duration
-
- All Implemented Interfaces:
Serializable,Comparable<Duration>
@Deprecated public class Duration extends Object implements Comparable<Duration>, Serializable
Deprecated.Please use standard Java 8 classes.Wraps a duration as the number of seconds as well as positive nanoseconds into an immutable value type.This will be deprecated once Java 8 is ubiquitous and only serves as an extremely simplified stop-gap.
- Author:
- AO Industries, Inc.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Duration(long seconds, int nano)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Durationbetween(Instant startInclusive, Instant endExclusive)Deprecated.intcompareTo(Duration other)Deprecated.booleanequals(Duration other)Deprecated.booleanequals(Object obj)Deprecated.intgetNano()Deprecated.The nanoseconds, to simplify this is always in the positive direction.longgetSeconds()Deprecated.inthashCode()Deprecated.protected ObjectreadResolve()Deprecated.longtoNanos()Deprecated.Gets this duration as a number of nanoseconds only.StringtoString()Deprecated.
-
-
-
Field Detail
-
ZERO
public static final Duration ZERO
Deprecated.
-
-
Method Detail
-
readResolve
protected Object readResolve()
Deprecated.
-
equals
public boolean equals(Duration other)
Deprecated.
-
compareTo
public int compareTo(Duration other)
Deprecated.- Specified by:
compareToin interfaceComparable<Duration>
-
getSeconds
public long getSeconds()
Deprecated.
-
getNano
public int getNano()
Deprecated.The nanoseconds, to simplify this is always in the positive direction. For negative durations, this means the nanos goes up from zero to 1 billion, then the seconds go up one (toward zero). This may be counterintuitive if one things of nanoseconds as a fractional part of seconds, but this definition leads to a very clean implementation.
Counting up by nanoseconds:
- -1.999999998
- -1.999999999
- 0.000000000
- 0.000000001
- 0.000000002
-
toNanos
public long toNanos() throws ArithmeticExceptionDeprecated.Gets this duration as a number of nanoseconds only. This covers a range around -292 years to +292 years.- Throws:
ArithmeticException- if duration is outside the range representable in nanoseconds
-
-