Class AmericanFormats

java.lang.Object
com.amalgamasimulation.utils.format.Formats
com.amalgamasimulation.utils.format.AmericanFormats

public class AmericanFormats extends Formats
  • Method Details

    • parseDayMonthLongYearHoursMinutes

      public LocalDateTime parseDayMonthLongYearHoursMinutes(String dateString)
      Specified by:
      parseDayMonthLongYearHoursMinutes in class Formats
    • parseDayMonthLongYear

      public LocalDateTime parseDayMonthLongYear(String dateString)
      Specified by:
      parseDayMonthLongYear in class Formats
    • parseHoursMinutes

      public LocalDateTime parseHoursMinutes(String dateString)
      Specified by:
      parseHoursMinutes in class Formats
    • getInstance

      public static AmericanFormats getInstance()
    • kmbShort

      public String kmbShort(double value)
      Description copied from class: Formats
      Convenient formatting for large values.

      Works almost like the Formats.kmb(double) method, but keeps at most one digit in the fractional part (if any).
      A single digit in the fractional part is shown only if that digit is the 2nd significant digit and is not zero:

      • kmbShort(1.6) is "1.6"
      • kmbShort(0.8) is "0.8"
      • kmbShort(9_400) is "9.4K"
      • kmbShort(-8_600_000) is "-8.6M"
      Otherwise, the fractional part is not shown:
      • kmbShort(0) is "0"
      • kmbShort(2) is "2"
      • kmbShort(12_000) is "12K"
      • kmbShort(4_000_000) is "4M"
      Uses the locale-specific decimals separator.
      Specified by:
      kmbShort in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
      See Also:
    • kmb

      public String kmb(double value)
      Description copied from class: Formats
      Convenient formatting for large values.
      Examples:
      • kmb(0) is "0.00"
      • kmb(12) is "12.0"
      • kmb(120) is "120"
      • kmb(1_200) is "1.20K"
      • kmb(1_200_098) is "1.20M"

      Uses the locale-specific decimals separator.
      Specified by:
      kmb in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • kmbDollars

      public String kmbDollars(double value)
      Description copied from class: Formats
      Returns the kmb-formatted value with the dollar character ($) in the beginning.
      Uses the locale-specific thousands separator.
      Specified by:
      kmbDollars in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
      See Also:
    • duration

      public String duration(long millis)
      Specified by:
      duration in class Formats
    • customDecimals

      public String customDecimals(double value, int countSign)
      Specified by:
      customDecimals in class Formats
    • noDecimals

      public String noDecimals(double value)
      Description copied from class: Formats
      Returns the specified value formatted without decimal separator and fractional part.
      Uses the locale-specific thousands separator.
      Specified by:
      noDecimals in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • twoDecimals

      public String twoDecimals(double value)
      Description copied from class: Formats
      Returns the specified value formatted with decimal separator and two digits of fractional part.
      Uses the locale-specific decimal and thousands separators.
      Specified by:
      twoDecimals in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • percent

      public String percent(double value)
      Description copied from class: Formats
      Returns the specified value formatted as whole percentage without fractional part and with the percent character (%) in the end.
      Note that the value is multiplied by 100 when converted to percentage.
      Specified by:
      percent in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • percentTwoDecimals

      public String percentTwoDecimals(double value)
      Description copied from class: Formats
      Returns the specified value formatted as percentage with two decimal digits and with the percent character (%) in the end.
      Note that the value is multiplied by 100 when converted to percentage.
      Specified by:
      percentTwoDecimals in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • dollar

      public String dollar(double value)
      Description copied from class: Formats
      Returns the specified value without fractional part and with the dollar character ($) in the beginning.
      Uses the locale-specific thousands separator.
      Specified by:
      dollar in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • dollarTwoDecimals

      public String dollarTwoDecimals(double value)
      Description copied from class: Formats
      Returns the specified value with two digits of fractional part and with dollar character ($) in the beginning.
      Uses the locale-specific decimal and thousands separators.
      Specified by:
      dollarTwoDecimals in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • noDecimalsSign

      public String noDecimalsSign(double value)
      Description copied from class: Formats
      Returns the string representation of the numeric value without any decimal points or fractional parts, including a leading sign (+ or -) based on the value's sign
      Specified by:
      noDecimalsSign in class Formats
      Parameters:
      value - The numeric value to format.
      Returns:
      A string representation of the numeric value with no decimals, including a leading sign to indicate positive or negative value
    • twoDecimalsSign

      public String twoDecimalsSign(double value)
      Description copied from class: Formats
      Returns a string representation of a numeric value formatted with two decimal places, including a leading sign (+ or -).
      Specified by:
      twoDecimalsSign in class Formats
      Parameters:
      value - The numeric value to format.
      Returns:
      A formatted string showing the numeric value with two decimal places and a leading sign
    • percentSign

      public String percentSign(double value)
      Description copied from class: Formats
      Returns a string representation of a numeric value formatted as a whole percentage, including a leading sign (+ or -) to indicate whether the percentage is positive or negative.
      Specified by:
      percentSign in class Formats
      Parameters:
      value - The numeric value to format as a percentage, typically a value between 0 and 1
      Returns:
      A string representing the numeric value as a whole percentage, with a leading sign
    • percentTwoDecimalsSign

      public String percentTwoDecimalsSign(double value)
      Description copied from class: Formats
      Returns a string representation of a numeric value formatted as a percentage with two decimal places, including a leading sign (+ or -).
      Specified by:
      percentTwoDecimalsSign in class Formats
      Parameters:
      value - The numeric value to format as a percentage, typically a value between 0 and 1
      Returns:
      A formatted string showing the percentage with two decimal places and a leading sign
    • dollarSign

      public String dollarSign(double value)
      Description copied from class: Formats
      Returns the specified value without fractional part and with the leading sign (+ or -) followed by the dollar character ($).
      Uses the locale-specific thousands separator.
      Specified by:
      dollarSign in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • dollarTwoDecimalsSign

      public String dollarTwoDecimalsSign(double value)
      Description copied from class: Formats
      Returns the specified value with two digits of fractional part and with the leading sign (+ or -) followed by the dollar character ($).
      Uses the locale-specific decimal and thousands separators.
      Specified by:
      dollarTwoDecimalsSign in class Formats
      Parameters:
      value - specified value
      Returns:
      string representation of the specified value
    • monthYear

      public String monthYear(LocalDate date)
      Specified by:
      monthYear in class Formats
    • dayMonthYear

      public String dayMonthYear(LocalDate date)
      Specified by:
      dayMonthYear in class Formats
    • monthLongYear

      public String monthLongYear(LocalDate date)
      Specified by:
      monthLongYear in class Formats
    • dayMonthLongYear

      public String dayMonthLongYear(LocalDate date)
      Specified by:
      dayMonthLongYear in class Formats
    • hoursMinutes

      public String hoursMinutes(LocalTime date)
      Specified by:
      hoursMinutes in class Formats
    • monthYear

      public String monthYear(LocalDateTime date)
      Specified by:
      monthYear in class Formats
    • dayMonthYear

      public String dayMonthYear(LocalDateTime date)
      Specified by:
      dayMonthYear in class Formats
    • monthLongYear

      public String monthLongYear(LocalDateTime date)
      Specified by:
      monthLongYear in class Formats
    • dayMonthLongYear

      public String dayMonthLongYear(LocalDateTime date)
      Specified by:
      dayMonthLongYear in class Formats
    • hoursMinutes

      public String hoursMinutes(LocalDateTime date)
      Specified by:
      hoursMinutes in class Formats
    • dayMonthLongYearHoursMinutes

      public String dayMonthLongYearHoursMinutes(LocalDateTime date)
      Specified by:
      dayMonthLongYearHoursMinutes in class Formats
    • preciseNumberFormat

      public String preciseNumberFormat(double value)
      Specified by:
      preciseNumberFormat in class Formats
    • dayMonthHoursMinutes

      public String dayMonthHoursMinutes(LocalDateTime date)
      Specified by:
      dayMonthHoursMinutes in class Formats
    • dayMonthLongYearHoursMinutesSeconds

      public String dayMonthLongYearHoursMinutesSeconds(LocalDateTime date)
      Specified by:
      dayMonthLongYearHoursMinutesSeconds in class Formats
    • currency

      public String currency(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value without fractional part and with the currency symbol ($, €, etc.) in the beginning.
      Uses the locale-specific thousands separator.
      Specified by:
      currency in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • currencyLong

      public String currencyLong(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value without fractional part and with the ISO 4217 currency code (USD, EUR, etc.) in the beginning.
      Uses the locale-specific thousands separator.
      Specified by:
      currencyLong in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • currencyTwoDecimals

      public String currencyTwoDecimals(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value with two digits of fractional part and with the currency symbol ($, €, etc.) in the beginning.
      Uses the locale-specific decimal and thousands separators.
      Specified by:
      currencyTwoDecimals in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • currencyLongTwoDecimals

      public String currencyLongTwoDecimals(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value with two digits of fractional part and with the ISO 4217 currency code (USD, EUR, etc.) in the beginning.
      Uses the locale-specific decimal and thousands separators.
      Specified by:
      currencyLongTwoDecimals in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • currencySign

      public String currencySign(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value without fractional part and with the leading sign (+ or -) followed by the currency symbol ($, €, etc.).
      Uses the locale-specific thousands separator.
      Specified by:
      currencySign in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • currencyLongSign

      public String currencyLongSign(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value without fractional part and with the leading sign (+ or -) followed by the ISO 4217 currency code (USD, EUR, etc.).
      Uses the locale-specific thousands separator.
      Specified by:
      currencyLongSign in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • currencyTwoDecimalsSign

      public String currencyTwoDecimalsSign(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value with two digits of fractional part and with the leading sign (+ or -) followed by the currency symbol ($, €, etc.).
      Uses the locale-specific decimal and thousands separators.
      Specified by:
      currencyTwoDecimalsSign in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • currencyLongTwoDecimalsSign

      public String currencyLongTwoDecimalsSign(double value, Currency currency)
      Description copied from class: Formats
      Returns the specified value with two digits of fractional part and with the leading sign (+ or -) followed by the ISO 4217 currency code (USD, EUR, etc.).
      Uses the locale-specific decimal and thousands separators.
      Specified by:
      currencyLongTwoDecimalsSign in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
    • kmbCurrency

      public String kmbCurrency(double value, Currency currency)
      Description copied from class: Formats
      Returns the kmb-formatted value with the currency symbol ($, €, etc.) in the beginning.
      Uses the locale-specific thousands separator.
      Specified by:
      kmbCurrency in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
      See Also:
    • kmbCurrencyLong

      public String kmbCurrencyLong(double value, Currency currency)
      Description copied from class: Formats
      Returns the kmb-formatted value with the ISO 4217 currency code (USD, EUR, etc.) in the beginning.
      Uses the locale-specific thousands separator.
      Specified by:
      kmbCurrencyLong in class Formats
      Parameters:
      value - specified value
      currency - currency of the value
      Returns:
      string representation of the specified value
      See Also: