Class Formatter

java.lang.Object
de.redstoneworld.redutilities.misc.Formatter

public class Formatter extends Object
  • Constructor Details

    • Formatter

      public Formatter()
  • Method Details

    • getTimeString

      public static String getTimeString(Date date, String format)
      This method returns the date object in the desired formatting.
      Parameters:
      date - (Date) the target date object
      format - (String) the format definition (based of the SimpleDateFormat)
      Returns:
      (String) the formatted time string
    • getTimeString

      public static String getTimeString(long timestamp, String format)
      This method returns the timestamp in the desired formatting.
      Parameters:
      timestamp - (long) the target timestamp
      format - (String) the format definition (based of the SimpleDateFormat)
      Returns:
      (String) the formatted time string
    • getRationalNumberValue

      public static double getRationalNumberValue(String cmdInput)
      This method reforms the rational number spelling and convert it to a double number. Flexible inputs are allowed, which improves the usability.
      Parameters:
      cmdInput - the rational number with one of all supported spellings
      Returns:
      (double) the formatted rational number (decimal value)
    • getRationalNumberMsg

      public static String getRationalNumberMsg(Locale locale, float floatValue, boolean grouping, int minFractionDigits)
      This method outputs the rational number as a string. This method uses the provided Locale to format the number according to its specific decimal separator, digit grouping logic and the grouping separator. Example:
      • Germany (de_DE): 12.345.678,9
      • US (en_US): 12,345,678.9
      • India (hi_IN): 1,23,45,678.9
      Large numeric values (such as values >= 10 million) are formatted in standard decimal form, not scientific notation (e.g., "10000000" instead of "1.0E7"), ensuring readability.
      Parameters:
      locale - (Locale) the Locale object for the specific micro-typography
      floatValue - (float) the rational number
      grouping - (boolean) Should the character grouping be used?
      minFractionDigits - (int) The minimum number of decimal digits to show
      Returns:
      (String) the formatted string
    • getRationalNumberMsg

      public static String getRationalNumberMsg(Locale locale, double doubleValue, boolean grouping, int minFractionDigits)
      This method outputs the rational number as a string. This method uses the provided Locale to format the number according to its specific decimal separator, digit grouping logic and the grouping separator. Example:
      • Germany (de_DE): 12.345.678,9
      • US (en_US): 12,345,678.9
      • India (hi_IN): 1,23,45,678.9
      Large numeric values (such as values >= 10 million) are formatted in standard decimal form, not scientific notation (e.g., "10000000" instead of "1.0E7"), ensuring readability.
      Parameters:
      locale - (Locale) the Locale object for the specific micro-typography
      doubleValue - (double) the rational number
      grouping - (boolean) Should the character grouping be used?
      minFractionDigits - (int) The minimum number of decimal digits to show
      Returns:
      (String) the formatted string