Package com.kamikazejam.kamicommon.util
Class TimeUtil
java.lang.Object
com.kamikazejam.kamicommon.util.TimeUtil
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull DategetDateBy24HourTime(int hour, int minute, int second, @NotNull TimeZone timeZone) static @NotNull DategetDateBy24HourTime(@NotNull String clockTime, @NotNull TimeZone timeZone) static @NotNull StringgetSecondsToTimeString(long seconds) Compiles current duration in theTimeUtil.TimeFormat.LETTERSformat:
"2d, 10h, 5m, 3s"when days > 0
"10h, 5m, 3s"when hours > 0
"5m, 3s"when minutes > 0
"3s"when seconds > 0static @NotNull StringgetSecondsToTimeString(long seconds, @NotNull TimeUtil.TimeFormat format) Returns the current time in the following formats:
TimeUtil.TimeFormat.LETTERS
"2d, 10h, 5m, 3s"when days > 0
"10h, 5m, 3s"when hours > 0
"5m, 3s"when minutes > 0
"3s"when seconds > 0
TimeUtil.TimeFormat.WORDS
"2 days, 10 hours, 5 minutes, 3 seconds"when days > 0
"10 hours, 5 minutes, 3 seconds"when hours > 0
"5 minutes, 3 seconds"when minutes > 0
"3 seconds"when seconds > 0
(The time word only includes the plural "s" when appropriate)
-
Constructor Details
-
TimeUtil
public TimeUtil()
-
-
Method Details
-
getSecondsToTimeString
Compiles current duration in theTimeUtil.TimeFormat.LETTERSformat:
"2d, 10h, 5m, 3s"when days > 0
"10h, 5m, 3s"when hours > 0
"5m, 3s"when minutes > 0
"3s"when seconds > 0 -
getSecondsToTimeString
@NotNull public static @NotNull String getSecondsToTimeString(long seconds, @NotNull @NotNull TimeUtil.TimeFormat format) Returns the current time in the following formats:
TimeUtil.TimeFormat.LETTERS
"2d, 10h, 5m, 3s"when days > 0
"10h, 5m, 3s"when hours > 0
"5m, 3s"when minutes > 0
"3s"when seconds > 0
TimeUtil.TimeFormat.WORDS
"2 days, 10 hours, 5 minutes, 3 seconds"when days > 0
"10 hours, 5 minutes, 3 seconds"when hours > 0
"5 minutes, 3 seconds"when minutes > 0
"3 seconds"when seconds > 0
(The time word only includes the plural "s" when appropriate) -
getDateBy24HourTime
@NotNull public static @NotNull Date getDateBy24HourTime(@NotNull @NotNull String clockTime, @NotNull @NotNull TimeZone timeZone) throws IllegalArgumentException - Parameters:
clockTime- A 24-hour time string formatted like "HH:mm" or "HH:mm:ss"timeZone- The time zone to use- Returns:
- a Date object representing that time of day in the nearest future
- Throws:
IllegalArgumentException
-
getDateBy24HourTime
@NotNull public static @NotNull Date getDateBy24HourTime(int hour, int minute, int second, @NotNull @NotNull TimeZone timeZone) - Parameters:
hour- The 24-hour time hour [0, 23]minute- The minute, [0, 59]second- The second, [0, 59]timeZone- The time zone to use- Returns:
- a Date object representing that time of day in the nearest future
-