Package org.silverpeas.core.util
Class UnitUtil
- java.lang.Object
-
- org.silverpeas.core.util.UnitUtil
-
public class UnitUtil extends Object
Unit values handling tools- Author:
- Yohann Chastagnier
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigDecimal
convertAndRoundTo(MemoryData memoryData, MemoryUnit to)
static BigDecimal
convertAndRoundTo(Duration duration, TimeUnit to)
static long
convertTo(long millisecondValue, TimeUnit to)
static long
convertTo(long value, TimeUnit from, TimeUnit to)
static long
convertTo(long byteValue, MemoryUnit to)
static long
convertTo(long value, MemoryUnit from, MemoryUnit to)
static BigDecimal
convertTo(BigDecimal millisecondValue, TimeUnit to)
static BigDecimal
convertTo(BigDecimal value, TimeUnit from, TimeUnit to)
static BigDecimal
convertTo(BigDecimal byteValue, MemoryUnit to)
static BigDecimal
convertTo(BigDecimal value, MemoryUnit from, MemoryUnit to)
static String
formatMemSize(long memSize)
Get the memory size with the suitable unitstatic String
formatMemSize(long memSize, MemoryUnit from)
Get the memory size with the suitable unitstatic String
formatMemSize(BigDecimal memSize)
Get the memory size with the suitable unitstatic String
formatMemSize(BigDecimal memSize, MemoryUnit from)
Get the memory size with the suitable unitstatic String
formatTime(long time)
Get the time with the suitable unitstatic String
formatTime(long time, TimeUnit from)
Get the time with the suitable unitstatic String
formatTime(BigDecimal time)
Get the time with the suitable unitstatic String
formatTime(BigDecimal time, TimeUnit from)
Get the time with the suitable unitstatic String
formatValue(long millisecondValue, TimeUnit to)
static String
formatValue(long value, TimeUnit from, TimeUnit to)
static String
formatValue(long byteValue, MemoryUnit to)
static String
formatValue(long value, MemoryUnit from, MemoryUnit to)
static String
formatValue(BigDecimal millisecondValue, TimeUnit to)
static String
formatValue(BigDecimal value, TimeUnit from, TimeUnit to)
static String
formatValue(BigDecimal byteValue, MemoryUnit to)
static String
formatValue(BigDecimal value, MemoryUnit from, MemoryUnit to)
static Duration
getDuration(long time)
Get the time datastatic Duration
getDuration(long time, TimeUnit from)
Get the time datastatic Duration
getDuration(BigDecimal time)
Get the time datastatic Duration
getDuration(BigDecimal time, TimeUnit from)
Get the time datastatic MemoryData
getMemData(long memSize)
Get the memory datastatic MemoryData
getMemData(long memSize, MemoryUnit from)
Get the memory datastatic MemoryData
getMemData(BigDecimal memSize)
Get the memory datastatic MemoryData
getMemData(BigDecimal memSize, MemoryUnit from)
Get the memory data
-
-
-
Method Detail
-
convertTo
public static long convertTo(long byteValue, MemoryUnit to)
-
convertTo
public static BigDecimal convertTo(BigDecimal byteValue, MemoryUnit to)
-
convertTo
public static long convertTo(long value, MemoryUnit from, MemoryUnit to)
-
convertTo
public static BigDecimal convertTo(BigDecimal value, MemoryUnit from, MemoryUnit to)
-
convertAndRoundTo
public static BigDecimal convertAndRoundTo(MemoryData memoryData, MemoryUnit to)
-
formatValue
public static String formatValue(long byteValue, MemoryUnit to)
-
formatValue
public static String formatValue(BigDecimal byteValue, MemoryUnit to)
-
formatValue
public static String formatValue(long value, MemoryUnit from, MemoryUnit to)
-
formatValue
public static String formatValue(BigDecimal value, MemoryUnit from, MemoryUnit to)
-
formatMemSize
public static String formatMemSize(long memSize)
Get the memory size with the suitable unit- Parameters:
memSize
- size in bytes- Returns:
- String
-
formatMemSize
public static String formatMemSize(BigDecimal memSize)
Get the memory size with the suitable unit- Parameters:
memSize
- size in bytes- Returns:
- String
-
formatMemSize
public static String formatMemSize(long memSize, MemoryUnit from)
Get the memory size with the suitable unit- Parameters:
memSize
- sizefrom
- the unit of the given size- Returns:
- String
-
formatMemSize
public static String formatMemSize(BigDecimal memSize, MemoryUnit from)
Get the memory size with the suitable unit- Parameters:
memSize
- sizefrom
- the unit of the given size- Returns:
- String
-
getMemData
public static MemoryData getMemData(long memSize)
Get the memory data- Parameters:
memSize
- size in bytes- Returns:
- MemoryData
-
getMemData
public static MemoryData getMemData(BigDecimal memSize)
Get the memory data- Parameters:
memSize
- size in bytes- Returns:
- MemoryData
-
getMemData
public static MemoryData getMemData(long memSize, MemoryUnit from)
Get the memory data- Parameters:
memSize
- sizefrom
- the unit of the given size- Returns:
- MemoryData
-
getMemData
public static MemoryData getMemData(BigDecimal memSize, MemoryUnit from)
Get the memory data- Parameters:
memSize
- sizefrom
- the unit of the given size- Returns:
- MemoryData
-
convertTo
public static long convertTo(long millisecondValue, TimeUnit to)
-
convertTo
public static BigDecimal convertTo(BigDecimal millisecondValue, TimeUnit to)
-
convertTo
public static BigDecimal convertTo(BigDecimal value, TimeUnit from, TimeUnit to)
-
convertAndRoundTo
public static BigDecimal convertAndRoundTo(Duration duration, TimeUnit to)
-
formatValue
public static String formatValue(BigDecimal millisecondValue, TimeUnit to)
-
formatValue
public static String formatValue(BigDecimal value, TimeUnit from, TimeUnit to)
-
formatTime
public static String formatTime(long time)
Get the time with the suitable unit- Parameters:
time
- in milliseconds- Returns:
- String
-
formatTime
public static String formatTime(BigDecimal time)
Get the time with the suitable unit- Parameters:
time
- in milliseconds- Returns:
- String
-
formatTime
public static String formatTime(long time, TimeUnit from)
Get the time with the suitable unit- Parameters:
time
- in millisecondsfrom
- the unit of the given size- Returns:
- String
-
formatTime
public static String formatTime(BigDecimal time, TimeUnit from)
Get the time with the suitable unit- Parameters:
time
- in millisecondsfrom
- the unit of the given size- Returns:
- String
-
getDuration
public static Duration getDuration(long time)
Get the time data- Parameters:
time
- in milliseconds- Returns:
- Duration
-
getDuration
public static Duration getDuration(BigDecimal time)
Get the time data- Parameters:
time
- in milliseconds- Returns:
- Duration
-
getDuration
public static Duration getDuration(long time, TimeUnit from)
Get the time data- Parameters:
time
- in millisecondsfrom
- the unit of the given size- Returns:
- Duration
-
getDuration
public static Duration getDuration(BigDecimal time, TimeUnit from)
Get the time data- Parameters:
time
- in millisecondsfrom
- the unit of the given size- Returns:
- Duration
-
-