Class UnitUtils

java.lang.Object
be.gaudry.model.UnitUtils

public final class UnitUtils extends Object
Allows to use and output units like time, length, weight, etc. Provided by the broldev.core.model project.
Since:
1.0 Jun 10, 2008, broldev.core.model 0.0.1-SNAPSHOT dependency
Version:
1.1 May 18, 2011
Author:
Steph GAUDRY
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static char
    Default value of "uninitialized" char.
    static int[]
    Powers of 10 prefixes according to the SI(International System of Units).
    static int[]
    Powers of 2 prefixes according to the SI(International System of Units).
    static String[]
    String representations of the electronic data quantity scale for the power of 10 prefixes according to the SI(International System of Units) "o", "ko", "Mo", "Go", "To"
    static String[]
    String representations of the electronic data quantity scale for the power of 2 prefixes according to the SI(International System of Units) "o", "kio", "Mio", "Gio", "Tio"
    static String[]
    String representations of the time scale TODO internationalize this
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    getDelay​(long start, long stop)
     
    static String
    getDelay​(long start, long stop, boolean nanoseconds)
     
    static String
    getLengthString​(long length)
    Returns a user friendly representation of the length, using the binary units multiples (1ko=1024octets).
    static String
    getLengthString​(long length, boolean useBinary)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNITS_OF_FILE_LENGTH_P2

      public static final String[] UNITS_OF_FILE_LENGTH_P2
      String representations of the electronic data quantity scale for the power of 2 prefixes according to the SI(International System of Units) "o", "kio", "Mio", "Gio", "Tio"
    • UNIT_MULTIPLES_P2

      public static final int[] UNIT_MULTIPLES_P2
      Powers of 2 prefixes according to the SI(International System of Units). \nExample: UNITS_MULTIPLES_P2[2]=20 is used for the Mio to represent x*220 octets
    • UNITS_OF_FILE_LENGTH_P10

      public static final String[] UNITS_OF_FILE_LENGTH_P10
      String representations of the electronic data quantity scale for the power of 10 prefixes according to the SI(International System of Units) "o", "ko", "Mo", "Go", "To"
    • UNIT_MULTIPLES_P10

      public static final int[] UNIT_MULTIPLES_P10
      Powers of 10 prefixes according to the SI(International System of Units). \nExample: UNITS_MULTIPLES_P2[2]=6 is used for the Mo to represent x*106 octets
    • UNITS_OF_TIME_SHORT

      public static final String[] UNITS_OF_TIME_SHORT
      String representations of the time scale TODO internationalize this
    • DEFAULT_CHAR

      public static final char DEFAULT_CHAR
      Default value of "uninitialized" char. This is a not printable character with ASCII value 0.
      See Also:
      Constant Field Values
  • Method Details

    • getDelay

      public static String getDelay(long start, long stop)
      Parameters:
      start -
      stop -
      Returns:
      String representation of the delay
    • getDelay

      public static String getDelay(long start, long stop, boolean nanoseconds)
      Parameters:
      start -
      stop -
      nanoseconds -
      Returns:
      String representation of the delay
    • getLengthString

      public static String getLengthString(long length)
      Returns a user friendly representation of the length, using the binary units multiples (1ko=1024octets).
      Parameters:
      length -
      Returns:
      String representation of the length
      See Also:
      getLengthString(long, false) for another representation (1kio=1000octets)
    • getLengthString

      public static String getLengthString(long length, boolean useBinary)
      Parameters:
      length -
      useBinary - true to compute for a binary representation (1kio=1024octets), false to compute as common representation (1ko=1000octets)
      Returns:
      String representation of the length
      Since:
      1.1 May 18, 2011