Package org.miaixz.bus.gitlab.models
Class Duration
java.lang.Object
org.miaixz.bus.gitlab.models.Duration
- All Implemented Interfaces:
Serializable
This class represents a duration in time.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DurationintGet the number of seconds this duration represents.static final intParses a human readable duration string and calculates the number of seconds it represents.voidsetSeconds(int seconds) Set the number of seconds this duration represents.toString()static final StringtoString(int durationSeconds) Create a human readable duration string from seconds.static final StringtoString(int durationSeconds, boolean includeMonths) Create a human readable duration string from seconds.
-
Constructor Details
-
Duration
Create a Duration instance from a human readable string. e.g: 3h30m- Parameters:
durationString- a duration in human readable format
-
Duration
public Duration(int seconds) Create a Duration instance from a number of seconds.- Parameters:
seconds- the number of seconds for this Duration instance to represent
-
-
Method Details
-
toString
Create a human readable duration string from seconds.- Parameters:
durationSeconds- the total number of seconds in the duration- Returns:
- a human readable string representing the duration
-
toString
Create a human readable duration string from seconds.- Parameters:
durationSeconds- the total number of seconds in the durationincludeMonths- when true will include months "mo", in the string otherwise uses "4w" for each month- Returns:
- a human readable string representing the duration
-
parse
Parses a human readable duration string and calculates the number of seconds it represents.- Parameters:
durationString- the human readable duration- Returns:
- the total number of seconds in the duration
-
getSeconds
public int getSeconds()Get the number of seconds this duration represents.- Returns:
- the number of seconds this duration represents
-
setSeconds
public void setSeconds(int seconds) Set the number of seconds this duration represents.- Parameters:
seconds- the number of seconds this duration represents
-
toString
-
forValue
-