Class UnitUtil


  • public class UnitUtil
    extends Object
    Unit values handling tools
    Author:
    Yohann Chastagnier
    • Method Detail

      • convertTo

        public static long convertTo​(long byteValue,
                                     MemoryUnit to)
      • formatValue

        public static String formatValue​(long byteValue,
                                         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 - size
        from - 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 - size
        from - 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 - size
        from - the unit of the given size
        Returns:
        MemoryData
      • getMemData

        public static MemoryData getMemData​(BigDecimal memSize,
                                            MemoryUnit from)
        Get the memory data
        Parameters:
        memSize - size
        from - the unit of the given size
        Returns:
        MemoryData
      • convertTo

        public static long convertTo​(long millisecondValue,
                                     TimeUnit to)
      • convertTo

        public static long convertTo​(long value,
                                     TimeUnit from,
                                     TimeUnit to)
      • formatValue

        public static String formatValue​(long millisecondValue,
                                         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 milliseconds
        from - 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 milliseconds
        from - 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 milliseconds
        from - the unit of the given size
        Returns:
        Duration
      • getDuration

        public static Duration getDuration​(BigDecimal time,
                                           TimeUnit from)
        Get the time data
        Parameters:
        time - in milliseconds
        from - the unit of the given size
        Returns:
        Duration