< prev index next >

src/java.base/share/classes/java/text/NumberFormat.java

Print this page




 164  *      It also works where there is no decimal, but possibly additional
 165  *      characters at the end, e.g., with parentheses in negative
 166  *      numbers: "(12)" for -12.
 167  * </ol>
 168  *
 169  * <h3><a id="synchronization">Synchronization</a></h3>
 170  *
 171  * <p>
 172  * Number formats are generally not synchronized.
 173  * It is recommended to create separate format instances for each thread.
 174  * If multiple threads access a format concurrently, it must be synchronized
 175  * externally.
 176  *
 177  * @implSpec The {@link #format(double, StringBuffer, FieldPosition)},
 178  * {@link #format(long, StringBuffer, FieldPosition)} and
 179  * {@link #parse(String, ParsePosition)} methods may throw
 180  * {@code NullPointerException}, if any of their parameter is {@code null}.
 181  * The subclass may provide its own implementation and specification about
 182  * {@code NullPointerException}.
 183  *












 184  * @see          DecimalFormat
 185  * @see          ChoiceFormat
 186  * @author       Mark Davis
 187  * @author       Helena Shih
 188  * @since 1.1
 189  */
 190 public abstract class NumberFormat extends Format  {
 191 
 192     /**
 193      * Field constant used to construct a FieldPosition object. Signifies that
 194      * the position of the integer part of a formatted number should be returned.
 195      * @see java.text.FieldPosition
 196      */
 197     public static final int INTEGER_FIELD = 0;
 198 
 199     /**
 200      * Field constant used to construct a FieldPosition object. Signifies that
 201      * the position of the fraction part of a formatted number should be returned.
 202      * @see java.text.FieldPosition
 203      */




 164  *      It also works where there is no decimal, but possibly additional
 165  *      characters at the end, e.g., with parentheses in negative
 166  *      numbers: "(12)" for -12.
 167  * </ol>
 168  *
 169  * <h3><a id="synchronization">Synchronization</a></h3>
 170  *
 171  * <p>
 172  * Number formats are generally not synchronized.
 173  * It is recommended to create separate format instances for each thread.
 174  * If multiple threads access a format concurrently, it must be synchronized
 175  * externally.
 176  *
 177  * @implSpec The {@link #format(double, StringBuffer, FieldPosition)},
 178  * {@link #format(long, StringBuffer, FieldPosition)} and
 179  * {@link #parse(String, ParsePosition)} methods may throw
 180  * {@code NullPointerException}, if any of their parameter is {@code null}.
 181  * The subclass may provide its own implementation and specification about
 182  * {@code NullPointerException}.
 183  *
 184  * @implSpec
 185  * <p>
 186  * {@code NumberFormat} provides rounding modes defined
 187  * in {@link java.math.RoundingMode} for formatting numbers. By default,
 188  * it uses the {@linkplain java.math.RoundingMode#HALF_EVEN
 189  * round half-even algorithm}. To change the rounding mode use
 190  * {@link #setRoundingMode(java.math.RoundingMode) setRoundingMode}.
 191  * The {@code NumberFormat} returned by the static factory methods is
 192  * configured to round floating point numbers using half-even
 193  * rounding (see {@link java.math.RoundingMode#HALF_EVEN
 194  * RoundingMode.HALF_EVEN}) for formatting.
 195  *
 196  * @see          DecimalFormat
 197  * @see          ChoiceFormat
 198  * @author       Mark Davis
 199  * @author       Helena Shih
 200  * @since 1.1
 201  */
 202 public abstract class NumberFormat extends Format  {
 203 
 204     /**
 205      * Field constant used to construct a FieldPosition object. Signifies that
 206      * the position of the integer part of a formatted number should be returned.
 207      * @see java.text.FieldPosition
 208      */
 209     public static final int INTEGER_FIELD = 0;
 210 
 211     /**
 212      * Field constant used to construct a FieldPosition object. Signifies that
 213      * the position of the fraction part of a formatted number should be returned.
 214      * @see java.text.FieldPosition
 215      */


< prev index next >