Package com.marcpg.libpg.data.time
Class Time
java.lang.Object
com.marcpg.libpg.data.time.Time
Time is used to convert and store times with different
Time.Unit
s, etc.- Since:
- 0.0.1
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
decrement
(long seconds) void
final boolean
long
get()
long
double
getAsExact
(@NotNull Time.Unit unit) void
void
increment
(long seconds) void
static @NotNull String
oneUnitFormat
(long s) static @NotNull String
oneUnitFormat
(@NotNull Time time) static @NotNull Time
Parse theinput string
to atime
.static @NotNull String
preciselyFormat
(long s) static @NotNull String
preciselyFormat
(@NotNull Time time) void
setAllowNegatives
(boolean allowNegatives) Changes whether the time allows negative values or not.toString()
-
Constructor Details
-
Method Details
-
getOneUnitFormatted
Get thetime
as a formattedstring
that is readable. The formattedtime
uses the highestTime.Unit
possible for the best readability. -
getPreciselyFormatted
Get thetime
as a formattedstring
that is readable. The formattedtime
uses the highestTime.Unit
possible and then lower ones for remaining time. -
get
public long get() -
getAs
-
getAsExact
-
increment
-
increment
public void increment(long seconds) -
increment
public void increment() -
decrement
-
decrement
public void decrement(long seconds) -
decrement
public void decrement() -
setAllowNegatives
public void setAllowNegatives(boolean allowNegatives) Changes whether the time allows negative values or not.- Parameters:
allowNegatives
- If the time allows negative values.- Since:
- 0.0.4
-
equals
-
toString
-
oneUnitFormat
-
oneUnitFormat
-
preciselyFormat
-
preciselyFormat
-
parse
Parse theinput string
to atime
. Useful for parsing text user input to a time object.- Parameters:
input
- String to parse, must follow the scheme: [time/int]+[abbreviation], so for example "1min", "3d", etc. Only one single unit is expected!- Returns:
- The parsed
time
. - Since:
- 0.0.3
-