public class Time extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
HOURS_IN_DAY
The number of hours in a day.
|
static long |
MINUTES_IN_DAY
The number of minutes in a day.
|
static long |
MINUTES_IN_HOUR
The number of minutes in an hour.
|
static long |
SECONDS_IN_DAY
The number of seconds in a day.
|
static long |
SECONDS_IN_HOUR
The number of seconds in an hour.
|
static long |
SECONDS_IN_MINUTE
The number of seconds in a minute.
|
long |
time
The time value.
|
TimeUnit |
unit
The time unit.
|
| Modifier and Type | Method and Description |
|---|---|
static Time |
current()
Creates and returns an object representing the current system time in milliseconds.
|
static Time |
currentNano()
Creates and returns an object representing the current high precision system time in
nanoseconds.
|
static Time |
days(long days)
Creates and returns an object representing the specified number of days.
|
Time |
daysTime()
Converts this time in days.
|
boolean |
equals(Object o) |
static Time |
fromUnit(long time,
TimeUnit unit)
Creates and returns an object representing the specified time value in the specified time
unit.
|
int |
hashCode() |
static Time |
hours(long hours)
Creates and returns an object representing the specified number of hours.
|
Time |
hoursTime()
Converts this time in hours.
|
boolean |
isZero()
Checks if this time is zero.
|
static Time |
micros(long micros)
Creates and returns an object representing the specified number of microseconds.
|
Time |
microsTime()
Converts this time in microseconds.
|
static Time |
millis(long millis)
Creates and returns an object representing the specified number of milliseconds.
|
Time |
millisTime()
Converts this time in milliseconds.
|
Time |
minus(Time time)
Returns a new instance whose time value is decremented by the specified one.
Note that the unit of the returned time will match the one with the highest precision. |
static Time |
minutes(long minutes)
Creates and returns an object representing the specified number of minutes.
|
Time |
minutesTime()
Converts this time in minutes.
|
static Time |
nanos(long nanos)
Creates and returns an object representing the specified number of nanoseconds.
|
Time |
nanosTime()
Converts this time in nanoseconds.
|
Time |
plus(Time time)
Returns a new instance whose time value is incremented by the specified one.
Note that the unit of the returned time will match the one with the highest precision. |
static Time |
seconds(long seconds)
Creates and returns an object representing the specified number of seconds.
|
Time |
secondsTime()
Converts this time in seconds.
|
long |
to(TimeUnit timeUnit)
Converts this time in the specified unit.
|
long |
toDays()
Converts this time in number of days.
|
long |
toHours()
Converts this time in number of hours.
|
long |
toMicros()
Converts this time in number of microseconds.
|
long |
toMillis()
Converts this time in number of milliseconds.
|
long |
toMinutes()
Converts this time in number of minutes.
|
long |
toNanos()
Converts this time in number of nanoseconds.
|
long |
toSeconds()
Converts this time in number of seconds.
|
String |
toString() |
public static final long HOURS_IN_DAY
public static final long MINUTES_IN_HOUR
public static final long MINUTES_IN_DAY
public static final long SECONDS_IN_MINUTE
public static final long SECONDS_IN_HOUR
public static final long SECONDS_IN_DAY
public final long time
public final TimeUnit unit
@NotNull public static Time current()
System.currentTimeMillis()@NotNull public static Time currentNano()
System.nanoTime()@NotNull public static Time days(long days)
days - the number of days.@NotNull public static Time fromUnit(long time, @NotNull TimeUnit unit)
time - the time value.unit - the time unit.@NotNull public static Time hours(long hours)
hours - the number of hours@NotNull public static Time micros(long micros)
micros - the number of microseconds.@NotNull public static Time millis(long millis)
millis - the number of milliseconds.@NotNull public static Time minutes(long minutes)
minutes - the number of minutes.@NotNull public static Time nanos(long nanos)
nanos - the number of nanoseconds.@NotNull public static Time seconds(long seconds)
seconds - the number of seconds.@NotNull public Time daysTime()
@NotNull public Time hoursTime()
public boolean isZero()
@NotNull public Time microsTime()
@NotNull public Time millisTime()
@NotNull public Time minus(@NotNull Time time)
time - the time to subtract.@NotNull public Time minutesTime()
@NotNull public Time nanosTime()
@NotNull public Time plus(@NotNull Time time)
time - the time to add.@NotNull public Time secondsTime()
public long to(@NotNull
TimeUnit timeUnit)
public long toDays()
public long toHours()
public long toMicros()
public long toMillis()
public long toMinutes()
public long toNanos()
public long toSeconds()