Class Misc

java.lang.Object
org.frankframework.util.Misc

public class Misc extends Object
Miscellaneous conversion functions.
  • Field Details

    • MESSAGE_SIZE_WARN_BY_DEFAULT_KEY

      public static final String MESSAGE_SIZE_WARN_BY_DEFAULT_KEY
      See Also:
    • LINE_SEPARATOR

      public static final String LINE_SEPARATOR
  • Method Details

    • getHostname

      public static String getHostname()
    • toFileSize

      public static long toFileSize(String value, long defaultValue)
      Converts the file size to bytes.
      Misc.toFileSize("14GB", 20); // gives out 15032385536
    • toFileSize

      public static String toFileSize(long bytes)
      See Also:
    • toFileSize

      public static String toFileSize(long bytes, boolean format)
      See Also:
    • toFileSize

      public static String toFileSize(long bytes, boolean format, boolean useSiUnits)
      Format bytes as human-readable text.
           String kbIecUnits = Misc.toFileSize(150000, false, false);                         // gives out "146KiB"
                 String mbIecUnits = Misc.toFileSize(15000000, true);                                 // gives out "14 MiB"
           String gbIecUnits = Misc.toFileSize(Long.parseLong("3221225472")); // gives out "3GiB"
      
                 String kbSiUnits = Misc.toFileSize(150000, true, false);                                             // gives out "150kB"
                 String mbSiUnits = Misc.toFileSize(15000000, true, true);                                            // gives out "15 MB"
                 String gbSiUnits = Misc.toFileSize(Long.parseLong("3221225472"), true, false);       // gives out "3GB"
       
      Parameters:
      bytes - Number of bytes. Should be positive, value is returned as string if negative.
      format - True to insert space between value and unit.
      useSiUnits - True to use metric (SI) units, aka powers of 1000. False to use binary (IEC), aka powers of 1024.
      Returns:
      Formatted string.
    • getMessageSizeWarnByDefault

      public static long getMessageSizeWarnByDefault()
    • getAge

      public static String getAge(long value)
    • getDurationInMs

      public static String getDurationInMs(long value)
    • parseAge

      public static long parseAge(String value, long defaultValue)
      Returns:
      'age' in milliseconds.
    • jsonPretty

      public static String jsonPretty(String json)