Package com.jgcomptech.tools
Class Misc.SecondsConverter
- java.lang.Object
-
- com.jgcomptech.tools.Misc.SecondsConverter
-
- Enclosing class:
- Misc
public static final class Misc.SecondsConverter extends java.lang.Object
Contains methods to convert seconds into a readable format.- Since:
- 1.3.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Misc.SecondsConverter.NegativeNumberException
This exception is thrown if a negative number is supplied to the methods in this class.
-
Field Summary
Fields Modifier and Type Field Description static int
Day
The number of seconds in a day.static int
Hour
The number of seconds in a hour.static int
Minute
The number of seconds in a minute.static int
SecondAwayFromADecade
One second less than the number of seconds in a decade.static int
Year
The number of seconds in a year.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
toString(long seconds)
Converts seconds into a readable format - years:days:hours:minutes:seconds.static java.lang.String
toString(long seconds, boolean allowNegative)
Converts seconds into a readable format - years:days:hours:minutes:seconds.
-
-
-
Field Detail
-
Minute
public static final int Minute
The number of seconds in a minute.- See Also:
- Constant Field Values
-
Hour
public static final int Hour
The number of seconds in a hour.- See Also:
- Constant Field Values
-
Day
public static final int Day
The number of seconds in a day.- See Also:
- Constant Field Values
-
Year
public static final int Year
The number of seconds in a year.- See Also:
- Constant Field Values
-
SecondAwayFromADecade
public static final int SecondAwayFromADecade
One second less than the number of seconds in a decade.- See Also:
- Constant Field Values
-
-
Method Detail
-
toString
public static java.lang.String toString(long seconds) throws Misc.SecondsConverter.NegativeNumberException
Converts seconds into a readable format - years:days:hours:minutes:seconds.- Parameters:
seconds
- the amount of seconds to convert- Returns:
- a readable string
- Throws:
Misc.SecondsConverter.NegativeNumberException
- if the specified number is negative
-
toString
public static java.lang.String toString(long seconds, boolean allowNegative) throws Misc.SecondsConverter.NegativeNumberException
Converts seconds into a readable format - years:days:hours:minutes:seconds.- Parameters:
seconds
- the amount of seconds to convertallowNegative
- if true and the number is negative a negative sign will be returned with the string- Returns:
- a readable string
- Throws:
Misc.SecondsConverter.NegativeNumberException
- if the specified number is negative and allowNegative is false
-
-