Package org.silverpeas.core.util.time
Class Duration
- java.lang.Object
-
- org.silverpeas.core.util.time.Duration
-
public class Duration extends Object
User: Yohann Chastagnier Date: 14/11/13
-
-
Constructor Summary
Constructors Constructor Description Duration(long time)
Duration(BigDecimal time)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BigDecimal
convertTo(BigDecimal value, TimeUnit from, TimeUnit to)
String
getBestDisplayValue()
Gets the best display valueString
getBestDisplayValueOnly()
Gets the best display valueTimeUnit
getBestUnit()
Gets the best unit (for display as example).BigDecimal
getBestValue()
Gets the best unformatted value (for display as example).String
getFormattedDuration(String format)
String
getFormattedDurationAsHMS()
String
getFormattedDurationAsHMSM()
String
getFormattedValue(TimeUnit to)
String
getFormattedValueOnly(TimeUnit to)
BigDecimal
getRoundedTimeConverted(TimeUnit to)
Gets the time converted to desired unit.BigDecimal
getTime()
Gets the time in milliseconds.Long
getTimeAsLong()
Gets the time in milliseconds.BigDecimal
getTimeConverted(TimeUnit to)
Gets the time converted to desired unit.
-
-
-
Constructor Detail
-
Duration
public Duration(long time)
-
Duration
public Duration(BigDecimal time)
-
-
Method Detail
-
convertTo
public static BigDecimal convertTo(BigDecimal value, TimeUnit from, TimeUnit to)
-
getTime
public BigDecimal getTime()
Gets the time in milliseconds.- Returns:
- the time in milliseconds
-
getTimeAsLong
public Long getTimeAsLong()
Gets the time in milliseconds.- Returns:
- the time in milliseconds.
-
getRoundedTimeConverted
public BigDecimal getRoundedTimeConverted(TimeUnit to)
Gets the time converted to desired unit.- Parameters:
to
- a time unit- Returns:
- the time converted to desired unit.
-
getTimeConverted
public BigDecimal getTimeConverted(TimeUnit to)
Gets the time converted to desired unit.- Parameters:
to
- a time unit- Returns:
- the time converted to desired unit.
-
getBestUnit
public TimeUnit getBestUnit()
Gets the best unit (for display as example).- Returns:
- the best unit
-
getBestValue
public BigDecimal getBestValue()
Gets the best unformatted value (for display as example).- Returns:
- the best unformatted value
-
getBestDisplayValueOnly
public String getBestDisplayValueOnly()
Gets the best display value- Returns:
- the best display value
-
getBestDisplayValue
public String getBestDisplayValue()
Gets the best display value- Returns:
- the best display value
-
getFormattedDurationAsHMSM
public String getFormattedDurationAsHMSM()
-
getFormattedDurationAsHMS
public String getFormattedDurationAsHMS()
-
-