Class DecimalStyle

java.lang.Object
java.time.format.DecimalStyle

public final class DecimalStyle extends Object
Localized decimal style used in date and time formatting.

A significant part of dealing with dates and times is the localization. This class acts as a central point for accessing the information.

Implementation Requirements:
This class is immutable and thread-safe.
Since:
1.8
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final DecimalStyle
    The standard set of non-localized decimal style symbols.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if this DecimalStyle is equal to another DecimalStyle.
    static Set<Locale>
    Lists all the locales that are supported.
    char
    Gets the character that represents the decimal point.
    char
    Gets the character that represents the negative sign.
    char
    Gets the character that represents the positive sign.
    char
    Gets the character that represents zero.
    int
    A hash code for this DecimalStyle.
    of(Locale locale)
    Obtains the DecimalStyle for the specified locale.
    Obtains the DecimalStyle for the default FORMAT locale.
    Returns a string describing this DecimalStyle.
    withDecimalSeparator(char decimalSeparator)
    Returns a copy of the info with a new character that represents the decimal point.
    withNegativeSign(char negativeSign)
    Returns a copy of the info with a new character that represents the negative sign.
    withPositiveSign(char positiveSign)
    Returns a copy of the info with a new character that represents the positive sign.
    withZeroDigit(char zeroDigit)
    Returns a copy of the info with a new character that represents zero.

    Methods declared in class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected Object
    Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • Field Details

    • STANDARD

      public static final DecimalStyle STANDARD
      The standard set of non-localized decimal style symbols.

      This uses standard ASCII characters for zero, positive, negative and a dot for the decimal point.

  • Method Details

    • getAvailableLocales

      public static Set<Locale> getAvailableLocales()
      Lists all the locales that are supported.

      At a minimum, the returned Set must contain a Locale instance equal to Locale.ROOT and a Locale instance equal to Locale.US.

      Returns:
      a Set of Locales for which localization is supported
    • ofDefaultLocale

      public static DecimalStyle ofDefaultLocale()
      Obtains the DecimalStyle for the default FORMAT locale.

      This method provides access to locale sensitive decimal style symbols.

      This is equivalent to calling of(Locale.getDefault(Locale.Category.FORMAT)).

      Returns:
      the decimal style, not null
      See Also:
    • of

      public static DecimalStyle of(Locale locale)
      Obtains the DecimalStyle for the specified locale.

      This method provides access to locale sensitive decimal style symbols. If the locale contains "nu" (Numbering System) and/or "rg" (Region Override) Unicode extensions, returned instance will reflect the values specified with those extensions. If both "nu" and "rg" are specified, the value from the "nu" extension supersedes the implicit one from the "rg" extension.

      Parameters:
      locale - the locale, not null
      Returns:
      the decimal style, not null
    • getZeroDigit

      public char getZeroDigit()
      Gets the character that represents zero.

      The character used to represent digits may vary by culture. This method specifies the zero character to use, which implies the characters for one to nine.

      Returns:
      the character for zero
    • withZeroDigit

      public DecimalStyle withZeroDigit(char zeroDigit)
      Returns a copy of the info with a new character that represents zero.

      The character used to represent digits may vary by culture. This method specifies the zero character to use, which implies the characters for one to nine.

      Parameters:
      zeroDigit - the character for zero
      Returns:
      a copy with a new character that represents zero, not null
    • getPositiveSign

      public char getPositiveSign()
      Gets the character that represents the positive sign.

      The character used to represent a positive number may vary by culture. This method specifies the character to use.

      Returns:
      the character for the positive sign
    • withPositiveSign

      public DecimalStyle withPositiveSign(char positiveSign)
      Returns a copy of the info with a new character that represents the positive sign.

      The character used to represent a positive number may vary by culture. This method specifies the character to use.

      Parameters:
      positiveSign - the character for the positive sign
      Returns:
      a copy with a new character that represents the positive sign, not null
    • getNegativeSign

      public char getNegativeSign()
      Gets the character that represents the negative sign.

      The character used to represent a negative number may vary by culture. This method specifies the character to use.

      Returns:
      the character for the negative sign
    • withNegativeSign

      public DecimalStyle withNegativeSign(char negativeSign)
      Returns a copy of the info with a new character that represents the negative sign.

      The character used to represent a negative number may vary by culture. This method specifies the character to use.

      Parameters:
      negativeSign - the character for the negative sign
      Returns:
      a copy with a new character that represents the negative sign, not null
    • getDecimalSeparator

      public char getDecimalSeparator()
      Gets the character that represents the decimal point.

      The character used to represent a decimal point may vary by culture. This method specifies the character to use.

      Returns:
      the character for the decimal point
    • withDecimalSeparator

      public DecimalStyle withDecimalSeparator(char decimalSeparator)
      Returns a copy of the info with a new character that represents the decimal point.

      The character used to represent a decimal point may vary by culture. This method specifies the character to use.

      Parameters:
      decimalSeparator - the character for the decimal point
      Returns:
      a copy with a new character that represents the decimal point, not null
    • equals

      public boolean equals(Object obj)
      Checks if this DecimalStyle is equal to another DecimalStyle.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to check, null returns false
      Returns:
      true if this is equal to the other date
      See Also:
    • hashCode

      public int hashCode()
      A hash code for this DecimalStyle.
      Overrides:
      hashCode in class Object
      Returns:
      a suitable hash code
      See Also:
    • toString

      public String toString()
      Returns a string describing this DecimalStyle.
      Overrides:
      toString in class Object
      Returns:
      a string description, not null