1// © 2016 and later: Unicode, Inc. and others. 2// License & terms of use: http://www.unicode.org/copyright.html#License 3/* 4 ******************************************************************************* 5 * Copyright (C) 1996-2012, International Business Machines Corporation and * 6 * others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9package com.ibm.icu.text; 10 11import java.math.BigInteger; 12import java.text.AttributedCharacterIterator; 13import java.text.AttributedCharacterIterator.Attribute; 14import java.text.AttributedString; 15import java.text.CharacterIterator; 16import java.text.FieldPosition; 17import java.text.ParsePosition; 18import java.util.Locale; 19import java.util.Map; 20import java.util.Map.Entry; 21 22import com.ibm.icu.math.BigDecimal; 23import com.ibm.icu.util.Currency; 24import com.ibm.icu.util.ULocale; 25import com.ibm.icu.util.ULocale.Category; 26 27/** 28 * {@icuenhanced java.text.DecimalFormat}.{@icu _usage_} 29 * 30 * <code>DecimalFormat</code> is a concrete subclass of {@link NumberFormat} that formats 31 * decimal numbers. It has a variety of features designed to make it possible to parse and 32 * format numbers in any locale, including support for Western, Arabic, or Indic digits. 33 * It also supports different flavors of numbers, including integers ("123"), fixed-point 34 * numbers ("123.4"), scientific notation ("1.23E4"), percentages ("12%"), and currency 35 * amounts ("$123.00", "USD123.00", "123.00 US dollars"). All of these flavors can be 36 * easily localized. 37 * 38 * <p>To obtain a {@link NumberFormat} for a specific locale (including the default 39 * locale) call one of <code>NumberFormat</code>'s factory methods such as {@link 40 * NumberFormat#getInstance}. Do not call the <code>DecimalFormat</code> constructors 41 * directly, unless you know what you are doing, since the {@link NumberFormat} factory 42 * methods may return subclasses other than <code>DecimalFormat</code>. If you need to 43 * customize the format object, do something like this: 44 * 45 * <blockquote><pre> 46 * NumberFormat f = NumberFormat.getInstance(loc); 47 * if (f instanceof DecimalFormat) { 48 * ((DecimalFormat) f).setDecimalSeparatorAlwaysShown(true); 49 * }</pre></blockquote> 50 * 51 * <p><strong>Example Usage</strong> 52 * 53 * Print out a number using the localized number, currency, and percent 54 * format for each locale. 55 * 56 * <blockquote><pre> 57 * Locale[] locales = NumberFormat.getAvailableLocales(); 58 * double myNumber = -1234.56; 59 * NumberFormat format; 60 * for (int j=0; j<3; ++j) { 61 * System.out.println("FORMAT"); 62 * for (int i = 0; i < locales.length; ++i) { 63 * if (locales[i].getCountry().length() == 0) { 64 * // Skip language-only locales 65 * continue; 66 * } 67 * System.out.print(locales[i].getDisplayName()); 68 * switch (j) { 69 * case 0: 70 * format = NumberFormat.getInstance(locales[i]); break; 71 * case 1: 72 * format = NumberFormat.getCurrencyInstance(locales[i]); break; 73 * default: 74 * format = NumberFormat.getPercentInstance(locales[i]); break; 75 * } 76 * try { 77 * // Assume format is a DecimalFormat 78 * System.out.print(": " + ((DecimalFormat) format).toPattern() 79 * + " -> " + form.format(myNumber)); 80 * } catch (Exception e) {} 81 * try { 82 * System.out.println(" -> " + format.parse(form.format(myNumber))); 83 * } catch (ParseException e) {} 84 * } 85 * }</pre></blockquote> 86 * 87 * <p>Another example use getInstance(style).<br/> 88 * Print out a number using the localized number, currency, percent, 89 * scientific, integer, iso currency, and plural currency format for each locale. 90 * 91 * <blockquote><pre> 92 * ULocale locale = new ULocale("en_US"); 93 * double myNumber = 1234.56; 94 * for (int j=NumberFormat.NUMBERSTYLE; j<=NumberFormat.PLURALCURRENCYSTYLE; ++j) { 95 * NumberFormat format = NumberFormat.getInstance(locale, j); 96 * try { 97 * // Assume format is a DecimalFormat 98 * System.out.print(": " + ((DecimalFormat) format).toPattern() 99 * + " -> " + form.format(myNumber)); 100 * } catch (Exception e) {} 101 * try { 102 * System.out.println(" -> " + format.parse(form.format(myNumber))); 103 * } catch (ParseException e) {} 104 * }</pre></blockquote> 105 * 106 * <h4>Patterns</h4> 107 * 108 * <p>A <code>DecimalFormat</code> consists of a <em>pattern</em> and a set of 109 * <em>symbols</em>. The pattern may be set directly using {@link #applyPattern}, or 110 * indirectly using other API methods which manipulate aspects of the pattern, such as the 111 * minimum number of integer digits. The symbols are stored in a {@link 112 * DecimalFormatSymbols} object. When using the {@link NumberFormat} factory methods, the 113 * pattern and symbols are read from ICU's locale data. 114 * 115 * <h4>Special Pattern Characters</h4> 116 * 117 * <p>Many characters in a pattern are taken literally; they are matched during parsing 118 * and output unchanged during formatting. Special characters, on the other hand, stand 119 * for other characters, strings, or classes of characters. For example, the '#' 120 * character is replaced by a localized digit. Often the replacement character is the 121 * same as the pattern character; in the U.S. locale, the ',' grouping character is 122 * replaced by ','. However, the replacement is still happening, and if the symbols are 123 * modified, the grouping character changes. Some special characters affect the behavior 124 * of the formatter by their presence; for example, if the percent character is seen, then 125 * the value is multiplied by 100 before being displayed. 126 * 127 * <p>To insert a special character in a pattern as a literal, that is, without any 128 * special meaning, the character must be quoted. There are some exceptions to this which 129 * are noted below. 130 * 131 * <p>The characters listed here are used in non-localized patterns. Localized patterns 132 * use the corresponding characters taken from this formatter's {@link 133 * DecimalFormatSymbols} object instead, and these characters lose their special status. 134 * Two exceptions are the currency sign and quote, which are not localized. 135 * 136 * <blockquote> 137 * <table border=0 cellspacing=3 cellpadding=0 summary="Chart showing symbol, 138 * location, localized, and meaning."> 139 * <tr bgcolor="#ccccff"> 140 * <th align=left>Symbol 141 * <th align=left>Location 142 * <th align=left>Localized? 143 * <th align=left>Meaning 144 * <tr valign=top> 145 * <td><code>0</code> 146 * <td>Number 147 * <td>Yes 148 * <td>Digit 149 * <tr valign=top bgcolor="#eeeeff"> 150 * <td><code>1-9</code> 151 * <td>Number 152 * <td>Yes 153 * <td>'1' through '9' indicate rounding. 154 * <tr valign=top> 155 * <td><code>@</code> 156 * <td>Number 157 * <td>No 158 * <td>Significant digit 159 * <tr valign=top bgcolor="#eeeeff"> 160 * <td><code>#</code> 161 * <td>Number 162 * <td>Yes 163 * <td>Digit, zero shows as absent 164 * <tr valign=top> 165 * <td><code>.</code> 166 * <td>Number 167 * <td>Yes 168 * <td>Decimal separator or monetary decimal separator 169 * <tr valign=top bgcolor="#eeeeff"> 170 * <td><code>-</code> 171 * <td>Number 172 * <td>Yes 173 * <td>Minus sign 174 * <tr valign=top> 175 * <td><code>,</code> 176 * <td>Number 177 * <td>Yes 178 * <td>Grouping separator 179 * <tr valign=top bgcolor="#eeeeff"> 180 * <td><code>E</code> 181 * <td>Number 182 * <td>Yes 183 * <td>Separates mantissa and exponent in scientific notation. 184 * <em>Need not be quoted in prefix or suffix.</em> 185 * <tr valign=top> 186 * <td><code>+</code> 187 * <td>Exponent 188 * <td>Yes 189 * <td>Prefix positive exponents with localized plus sign. 190 * <em>Need not be quoted in prefix or suffix.</em> 191 * <tr valign=top bgcolor="#eeeeff"> 192 * <td><code>;</code> 193 * <td>Subpattern boundary 194 * <td>Yes 195 * <td>Separates positive and negative subpatterns 196 * <tr valign=top> 197 * <td><code>%</code> 198 * <td>Prefix or suffix 199 * <td>Yes 200 * <td>Multiply by 100 and show as percentage 201 * <tr valign=top bgcolor="#eeeeff"> 202 * <td><code>\u2030</code> 203 * <td>Prefix or suffix 204 * <td>Yes 205 * <td>Multiply by 1000 and show as per mille 206 * <tr valign=top> 207 * <td><code>¤</code> (<code>\u00A4</code>) 208 * <td>Prefix or suffix 209 * <td>No 210 * <td>Currency sign, replaced by currency symbol. If 211 * doubled, replaced by international currency symbol. 212 * If tripled, replaced by currency plural names, for example, 213 * "US dollar" or "US dollars" for America. 214 * If present in a pattern, the monetary decimal separator 215 * is used instead of the decimal separator. 216 * <tr valign=top bgcolor="#eeeeff"> 217 * <td><code>'</code> 218 * <td>Prefix or suffix 219 * <td>No 220 * <td>Used to quote special characters in a prefix or suffix, 221 * for example, <code>"'#'#"</code> formats 123 to 222 * <code>"#123"</code>. To create a single quote 223 * itself, use two in a row: <code>"# o''clock"</code>. 224 * <tr valign=top> 225 * <td><code>*</code> 226 * <td>Prefix or suffix boundary 227 * <td>Yes 228 * <td>Pad escape, precedes pad character 229 * </table> 230 * </blockquote> 231 * 232 * <p>A <code>DecimalFormat</code> pattern contains a postive and negative subpattern, for 233 * example, "#,##0.00;(#,##0.00)". Each subpattern has a prefix, a numeric part, and a 234 * suffix. If there is no explicit negative subpattern, the negative subpattern is the 235 * localized minus sign prefixed to the positive subpattern. That is, "0.00" alone is 236 * equivalent to "0.00;-0.00". If there is an explicit negative subpattern, it serves 237 * only to specify the negative prefix and suffix; the number of digits, minimal digits, 238 * and other characteristics are ignored in the negative subpattern. That means that 239 * "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)". 240 * 241 * <p>The prefixes, suffixes, and various symbols used for infinity, digits, thousands 242 * separators, decimal separators, etc. may be set to arbitrary values, and they will 243 * appear properly during formatting. However, care must be taken that the symbols and 244 * strings do not conflict, or parsing will be unreliable. For example, either the 245 * positive and negative prefixes or the suffixes must be distinct for {@link #parse} to 246 * be able to distinguish positive from negative values. Another example is that the 247 * decimal separator and thousands separator should be distinct characters, or parsing 248 * will be impossible. 249 * 250 * <p>The <em>grouping separator</em> is a character that separates clusters of integer 251 * digits to make large numbers more legible. It commonly used for thousands, but in some 252 * locales it separates ten-thousands. The <em>grouping size</em> is the number of digits 253 * between the grouping separators, such as 3 for "100,000,000" or 4 for "1 0000 254 * 0000". There are actually two different grouping sizes: One used for the least 255 * significant integer digits, the <em>primary grouping size</em>, and one used for all 256 * others, the <em>secondary grouping size</em>. In most locales these are the same, but 257 * sometimes they are different. For example, if the primary grouping interval is 3, and 258 * the secondary is 2, then this corresponds to the pattern "#,##,##0", and the number 259 * 123456789 is formatted as "12,34,56,789". If a pattern contains multiple grouping 260 * separators, the interval between the last one and the end of the integer defines the 261 * primary grouping size, and the interval between the last two defines the secondary 262 * grouping size. All others are ignored, so "#,##,###,####" == "###,###,####" == 263 * "##,#,###,####". 264 * 265 * <p>Illegal patterns, such as "#.#.#" or "#.###,###", will cause 266 * <code>DecimalFormat</code> to throw an {@link IllegalArgumentException} with a message 267 * that describes the problem. 268 * 269 * <h4>Pattern BNF</h4> 270 * 271 * <pre> 272 * pattern := subpattern (';' subpattern)? 273 * subpattern := prefix? number exponent? suffix? 274 * number := (integer ('.' fraction)?) | sigDigits 275 * prefix := '\u0000'..'\uFFFD' - specialCharacters 276 * suffix := '\u0000'..'\uFFFD' - specialCharacters 277 * integer := '#'* '0'* '0' 278 * fraction := '0'* '#'* 279 * sigDigits := '#'* '@' '@'* '#'* 280 * exponent := 'E' '+'? '0'* '0' 281 * padSpec := '*' padChar 282 * padChar := '\u0000'..'\uFFFD' - quote 283 *   284 * Notation: 285 * X* 0 or more instances of X 286 * X? 0 or 1 instances of X 287 * X|Y either X or Y 288 * C..D any character from C up to D, inclusive 289 * S-T characters in S, except those in T 290 * </pre> 291 * The first subpattern is for positive numbers. The second (optional) 292 * subpattern is for negative numbers. 293 * 294 * <p>Not indicated in the BNF syntax above: 295 * 296 * <ul> 297 * 298 * <li>The grouping separator ',' can occur inside the integer and sigDigits 299 * elements, between any two pattern characters of that element, as long as the integer or 300 * sigDigits element is not followed by the exponent element. 301 * 302 * <li>Two grouping intervals are recognized: That between the decimal point and the first 303 * grouping symbol, and that between the first and second grouping symbols. These 304 * intervals are identical in most locales, but in some locales they differ. For example, 305 * the pattern "#,##,###" formats the number 123456789 as 306 * "12,34,56,789". 307 * 308 * <li>The pad specifier <code>padSpec</code> may appear before the prefix, after the 309 * prefix, before the suffix, after the suffix, or not at all. 310 * 311 * <li>In place of '0', the digits '1' through '9' may be used to indicate a rounding 312 * increment. 313 * 314 * </ul> 315 * 316 * <h4>Parsing</h4> 317 * 318 * <p><code>DecimalFormat</code> parses all Unicode characters that represent decimal 319 * digits, as defined by {@link UCharacter#digit}. In addition, 320 * <code>DecimalFormat</code> also recognizes as digits the ten consecutive characters 321 * starting with the localized zero digit defined in the {@link DecimalFormatSymbols} 322 * object. During formatting, the {@link DecimalFormatSymbols}-based digits are output. 323 * 324 * <p>During parsing, grouping separators are ignored. 325 * 326 * <p>For currency parsing, the formatter is able to parse every currency style formats no 327 * matter which style the formatter is constructed with. For example, a formatter 328 * instance gotten from NumberFormat.getInstance(ULocale, NumberFormat.CURRENCYSTYLE) can 329 * parse formats such as "USD1.00" and "3.00 US dollars". 330 * 331 * <p>If {@link #parse(String, ParsePosition)} fails to parse a string, it returns 332 * <code>null</code> and leaves the parse position unchanged. The convenience method 333 * {@link #parse(String)} indicates parse failure by throwing a {@link 334 * java.text.ParseException}. 335 * 336 * <h4>Formatting</h4> 337 * 338 * <p>Formatting is guided by several parameters, all of which can be specified either 339 * using a pattern or using the API. The following description applies to formats that do 340 * not use <a href="#sci">scientific notation</a> or <a href="#sigdig">significant 341 * digits</a>. 342 * 343 * <ul><li>If the number of actual integer digits exceeds the <em>maximum integer 344 * digits</em>, then only the least significant digits are shown. For example, 1997 is 345 * formatted as "97" if the maximum integer digits is set to 2. 346 * 347 * <li>If the number of actual integer digits is less than the <em>minimum integer 348 * digits</em>, then leading zeros are added. For example, 1997 is formatted as "01997" 349 * if the minimum integer digits is set to 5. 350 * 351 * <li>If the number of actual fraction digits exceeds the <em>maximum fraction 352 * digits</em>, then half-even rounding it performed to the maximum fraction digits. For 353 * example, 0.125 is formatted as "0.12" if the maximum fraction digits is 2. This 354 * behavior can be changed by specifying a rounding increment and a rounding mode. 355 * 356 * <li>If the number of actual fraction digits is less than the <em>minimum fraction 357 * digits</em>, then trailing zeros are added. For example, 0.125 is formatted as 358 * "0.1250" if the mimimum fraction digits is set to 4. 359 * 360 * <li>Trailing fractional zeros are not displayed if they occur <em>j</em> positions 361 * after the decimal, where <em>j</em> is less than the maximum fraction digits. For 362 * example, 0.10004 is formatted as "0.1" if the maximum fraction digits is four or less. 363 * </ul> 364 * 365 * <p><strong>Special Values</strong> 366 * 367 * <p><code>NaN</code> is represented as a single character, typically 368 * <code>\uFFFD</code>. This character is determined by the {@link 369 * DecimalFormatSymbols} object. This is the only value for which the prefixes and 370 * suffixes are not used. 371 * 372 * <p>Infinity is represented as a single character, typically <code>\u221E</code>, 373 * with the positive or negative prefixes and suffixes applied. The infinity character is 374 * determined by the {@link DecimalFormatSymbols} object. 375 * 376 * <a name="sci"><h4>Scientific Notation</h4></a> 377 * 378 * <p>Numbers in scientific notation are expressed as the product of a mantissa and a 379 * power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>. The 380 * mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0), 381 * but it need not be. <code>DecimalFormat</code> supports arbitrary mantissas. 382 * <code>DecimalFormat</code> can be instructed to use scientific notation through the API 383 * or through the pattern. In a pattern, the exponent character immediately followed by 384 * one or more digit characters indicates scientific notation. Example: "0.###E0" formats 385 * the number 1234 as "1.234E3". 386 * 387 * <ul> 388 * 389 * <li>The number of digit characters after the exponent character gives the minimum 390 * exponent digit count. There is no maximum. Negative exponents are formatted using the 391 * localized minus sign, <em>not</em> the prefix and suffix from the pattern. This allows 392 * patterns such as "0.###E0 m/s". To prefix positive exponents with a localized plus 393 * sign, specify '+' between the exponent and the digits: "0.###E+0" will produce formats 394 * "1E+1", "1E+0", "1E-1", etc. (In localized patterns, use the localized plus sign 395 * rather than '+'.) 396 * 397 * <li>The minimum number of integer digits is achieved by adjusting the exponent. 398 * Example: 0.00123 formatted with "00.###E0" yields "12.3E-4". This only happens if 399 * there is no maximum number of integer digits. If there is a maximum, then the minimum 400 * number of integer digits is fixed at one. 401 * 402 * <li>The maximum number of integer digits, if present, specifies the exponent grouping. 403 * The most common use of this is to generate <em>engineering notation</em>, in which the 404 * exponent is a multiple of three, e.g., "##0.###E0". The number 12345 is formatted 405 * using "##0.####E0" as "12.345E3". 406 * 407 * <li>When using scientific notation, the formatter controls the digit counts using 408 * significant digits logic. The maximum number of significant digits limits the total 409 * number of integer and fraction digits that will be shown in the mantissa; it does not 410 * affect parsing. For example, 12345 formatted with "##0.##E0" is "12.3E3". See the 411 * section on significant digits for more details. 412 * 413 * <li>The number of significant digits shown is determined as follows: If 414 * areSignificantDigitsUsed() returns false, then the minimum number of significant digits 415 * shown is one, and the maximum number of significant digits shown is the sum of the 416 * <em>minimum integer</em> and <em>maximum fraction</em> digits, and is unaffected by the 417 * maximum integer digits. If this sum is zero, then all significant digits are shown. 418 * If areSignificantDigitsUsed() returns true, then the significant digit counts are 419 * specified by getMinimumSignificantDigits() and getMaximumSignificantDigits(). In this 420 * case, the number of integer digits is fixed at one, and there is no exponent grouping. 421 * 422 * <li>Exponential patterns may not contain grouping separators. 423 * 424 * </ul> 425 * 426 * <a name="sigdig"><h4>Significant Digits</h4></a> 427 * 428 * <code>DecimalFormat</code> has two ways of controlling how many digits are shows: (a) 429 * significant digits counts, or (b) integer and fraction digit counts. Integer and 430 * fraction digit counts are described above. When a formatter is using significant 431 * digits counts, the number of integer and fraction digits is not specified directly, and 432 * the formatter settings for these counts are ignored. Instead, the formatter uses 433 * however many integer and fraction digits are required to display the specified number 434 * of significant digits. Examples: 435 * 436 * <blockquote> 437 * <table border=0 cellspacing=3 cellpadding=0> 438 * <tr bgcolor="#ccccff"> 439 * <th align=left>Pattern 440 * <th align=left>Minimum significant digits 441 * <th align=left>Maximum significant digits 442 * <th align=left>Number 443 * <th align=left>Output of format() 444 * <tr valign=top> 445 * <td><code>@@@</code> 446 * <td>3 447 * <td>3 448 * <td>12345 449 * <td><code>12300</code> 450 * <tr valign=top bgcolor="#eeeeff"> 451 * <td><code>@@@</code> 452 * <td>3 453 * <td>3 454 * <td>0.12345 455 * <td><code>0.123</code> 456 * <tr valign=top> 457 * <td><code>@@##</code> 458 * <td>2 459 * <td>4 460 * <td>3.14159 461 * <td><code>3.142</code> 462 * <tr valign=top bgcolor="#eeeeff"> 463 * <td><code>@@##</code> 464 * <td>2 465 * <td>4 466 * <td>1.23004 467 * <td><code>1.23</code> 468 * </table> 469 * </blockquote> 470 * 471 * <ul> 472 * 473 * <li>Significant digit counts may be expressed using patterns that specify a minimum and 474 * maximum number of significant digits. These are indicated by the <code>'@'</code> and 475 * <code>'#'</code> characters. The minimum number of significant digits is the number of 476 * <code>'@'</code> characters. The maximum number of significant digits is the number of 477 * <code>'@'</code> characters plus the number of <code>'#'</code> characters following on 478 * the right. For example, the pattern <code>"@@@"</code> indicates exactly 3 significant 479 * digits. The pattern <code>"@##"</code> indicates from 1 to 3 significant digits. 480 * Trailing zero digits to the right of the decimal separator are suppressed after the 481 * minimum number of significant digits have been shown. For example, the pattern 482 * <code>"@##"</code> formats the number 0.1203 as <code>"0.12"</code>. 483 * 484 * <li>If a pattern uses significant digits, it may not contain a decimal separator, nor 485 * the <code>'0'</code> pattern character. Patterns such as <code>"@00"</code> or 486 * <code>"@.###"</code> are disallowed. 487 * 488 * <li>Any number of <code>'#'</code> characters may be prepended to the left of the 489 * leftmost <code>'@'</code> character. These have no effect on the minimum and maximum 490 * significant digits counts, but may be used to position grouping separators. For 491 * example, <code>"#,#@#"</code> indicates a minimum of one significant digits, a maximum 492 * of two significant digits, and a grouping size of three. 493 * 494 * <li>In order to enable significant digits formatting, use a pattern containing the 495 * <code>'@'</code> pattern character. Alternatively, call {@link 496 * #setSignificantDigitsUsed setSignificantDigitsUsed(true)}. 497 * 498 * <li>In order to disable significant digits formatting, use a pattern that does not 499 * contain the <code>'@'</code> pattern character. Alternatively, call {@link 500 * #setSignificantDigitsUsed setSignificantDigitsUsed(false)}. 501 * 502 * <li>The number of significant digits has no effect on parsing. 503 * 504 * <li>Significant digits may be used together with exponential notation. Such patterns 505 * are equivalent to a normal exponential pattern with a minimum and maximum integer digit 506 * count of one, a minimum fraction digit count of <code>getMinimumSignificantDigits() - 507 * 1</code>, and a maximum fraction digit count of <code>getMaximumSignificantDigits() - 508 * 1</code>. For example, the pattern <code>"@@###E0"</code> is equivalent to 509 * <code>"0.0###E0"</code>. 510 * 511 * <li>If signficant digits are in use, then the integer and fraction digit counts, as set 512 * via the API, are ignored. If significant digits are not in use, then the signficant 513 * digit counts, as set via the API, are ignored. 514 * 515 * </ul> 516 * 517 * <h4>Padding</h4> 518 * 519 * <p><code>DecimalFormat</code> supports padding the result of {@link #format} to a 520 * specific width. Padding may be specified either through the API or through the pattern 521 * syntax. In a pattern the pad escape character, followed by a single pad character, 522 * causes padding to be parsed and formatted. The pad escape character is '*' in 523 * unlocalized patterns, and can be localized using {@link 524 * DecimalFormatSymbols#setPadEscape}. For example, <code>"$*x#,##0.00"</code> formats 525 * 123 to <code>"$xx123.00"</code>, and 1234 to <code>"$1,234.00"</code>. 526 * 527 * <ul> 528 * 529 * <li>When padding is in effect, the width of the positive subpattern, including prefix 530 * and suffix, determines the format width. For example, in the pattern <code>"* #0 531 * o''clock"</code>, the format width is 10. 532 * 533 * <li>The width is counted in 16-bit code units (Java <code>char</code>s). 534 * 535 * <li>Some parameters which usually do not matter have meaning when padding is used, 536 * because the pattern width is significant with padding. In the pattern "* 537 * ##,##,#,##0.##", the format width is 14. The initial characters "##,##," do not affect 538 * the grouping size or maximum integer digits, but they do affect the format width. 539 * 540 * <li>Padding may be inserted at one of four locations: before the prefix, after the 541 * prefix, before the suffix, or after the suffix. If padding is specified in any other 542 * location, {@link #applyPattern} throws an {@link IllegalArgumentException}. If there 543 * is no prefix, before the prefix and after the prefix are equivalent, likewise for the 544 * suffix. 545 * 546 * <li>When specified in a pattern, the 16-bit <code>char</code> immediately following the 547 * pad escape is the pad character. This may be any character, including a special pattern 548 * character. That is, the pad escape <em>escapes</em> the following character. If there 549 * is no character after the pad escape, then the pattern is illegal. 550 * 551 * </ul> 552 * 553 * <p> 554 * <strong>Rounding</strong> 555 * 556 * <p><code>DecimalFormat</code> supports rounding to a specific increment. For example, 557 * 1230 rounded to the nearest 50 is 1250. 1.234 rounded to the nearest 0.65 is 1.3. The 558 * rounding increment may be specified through the API or in a pattern. To specify a 559 * rounding increment in a pattern, include the increment in the pattern itself. "#,#50" 560 * specifies a rounding increment of 50. "#,##0.05" specifies a rounding increment of 561 * 0.05. 562 * 563 * <ul> 564 * 565 * <li>Rounding only affects the string produced by formatting. It does not affect 566 * parsing or change any numerical values. 567 * 568 * <li>A <em>rounding mode</em> determines how values are rounded; see the {@link 569 * com.ibm.icu.math.BigDecimal} documentation for a description of the modes. Rounding 570 * increments specified in patterns use the default mode, {@link 571 * com.ibm.icu.math.BigDecimal#ROUND_HALF_EVEN}. 572 * 573 * <li>Some locales use rounding in their currency formats to reflect the smallest 574 * currency denomination. 575 * 576 * <li>In a pattern, digits '1' through '9' specify rounding, but otherwise behave 577 * identically to digit '0'. 578 * 579 * </ul> 580 * 581 * <h4>Synchronization</h4> 582 * 583 * <p><code>DecimalFormat</code> objects are not synchronized. Multiple threads should 584 * not access one formatter concurrently. 585 * 586 * @see java.text.Format 587 * @see NumberFormat 588 * @author Mark Davis 589 * @author Alan Liu 590 * @stable ICU 2.0 591 */ 592public class DecimalFormat extends NumberFormat { 593 594 private static final long serialVersionUID = 1L; 595 /** 596 * @internal 597 * @param delegate the NumberFormat to which to delegate 598 */ 599 public DecimalFormat(java.text.DecimalFormat delegate) { 600 super(delegate); 601 } 602 603 /** 604 * Creates a DecimalFormat using the default pattern and symbols for the default 605 * locale. This is a convenient way to obtain a DecimalFormat when 606 * internationalization is not the main concern. 607 * 608 * <p>To obtain standard formats for a given locale, use the factory methods on 609 * NumberFormat such as getNumberInstance. These factories will return the most 610 * appropriate sub-class of NumberFormat for a given locale. 611 * 612 * @see NumberFormat#getInstance 613 * @see NumberFormat#getNumberInstance 614 * @see NumberFormat#getCurrencyInstance 615 * @see NumberFormat#getPercentInstance 616 * @stable ICU 2.0 617 */ 618 public DecimalFormat() { 619 // There is no way to construct java.text.DecimalFormat with an 620 // explicit Locale. 621 this(new java.text.DecimalFormat()); 622 623 if (!ULocale.getDefault(Category.FORMAT).toLocale().equals(Locale.getDefault())) { 624 // On Java 6 or older JRE, ULocale's FORMAT default might be different 625 // from the locale used for constructing java.text.DecimalFormat 626 java.text.NumberFormat jdkNfmt = java.text.NumberFormat.getInstance(ULocale.getDefault(Category.FORMAT).toLocale()); 627 if (jdkNfmt instanceof java.text.DecimalFormat) { 628 ((java.text.DecimalFormat)numberFormat).applyPattern(((java.text.DecimalFormat)jdkNfmt).toPattern()); 629 ((java.text.DecimalFormat)numberFormat).setDecimalFormatSymbols(((java.text.DecimalFormat)jdkNfmt).getDecimalFormatSymbols()); 630 } 631 } 632 } 633 634 /** 635 * Creates a DecimalFormat from the given pattern and the symbols for the default 636 * locale. This is a convenient way to obtain a DecimalFormat when 637 * internationalization is not the main concern. 638 * 639 * <p>To obtain standard formats for a given locale, use the factory methods on 640 * NumberFormat such as getNumberInstance. These factories will return the most 641 * appropriate sub-class of NumberFormat for a given locale. 642 * 643 * @param pattern A non-localized pattern string. 644 * @throws IllegalArgumentException if the given pattern is invalid. 645 * @see NumberFormat#getInstance 646 * @see NumberFormat#getNumberInstance 647 * @see NumberFormat#getCurrencyInstance 648 * @see NumberFormat#getPercentInstance 649 * @stable ICU 2.0 650 */ 651 public DecimalFormat(String pattern) { 652 this(new java.text.DecimalFormat( 653 pattern, 654 new java.text.DecimalFormatSymbols(ULocale.getDefault(Category.FORMAT).toLocale()))); 655 } 656 657 /** 658 * Creates a DecimalFormat from the given pattern and symbols. Use this constructor 659 * when you need to completely customize the behavior of the format. 660 * 661 * <p>To obtain standard formats for a given locale, use the factory methods on 662 * NumberFormat such as getInstance or getCurrencyInstance. If you need only minor 663 * adjustments to a standard format, you can modify the format returned by a 664 * NumberFormat factory method. 665 * 666 * @param pattern a non-localized pattern string 667 * @param symbols the set of symbols to be used 668 * @exception IllegalArgumentException if the given pattern is invalid 669 * @see NumberFormat#getInstance 670 * @see NumberFormat#getNumberInstance 671 * @see NumberFormat#getCurrencyInstance 672 * @see NumberFormat#getPercentInstance 673 * @see DecimalFormatSymbols 674 * @stable ICU 2.0 675 */ 676 public DecimalFormat(String pattern, DecimalFormatSymbols symbols) { 677 this(new java.text.DecimalFormat(pattern, symbols.dfs)); 678 } 679 680// /** 681// * Creates a DecimalFormat from the given pattern, symbols, information used for 682// * currency plural format, and format style. Use this constructor when you need to 683// * completely customize the behavior of the format. 684// * 685// * <p>To obtain standard formats for a given locale, use the factory methods on 686// * NumberFormat such as getInstance or getCurrencyInstance. 687// * 688// * <p>If you need only minor adjustments to a standard format, you can modify the 689// * format returned by a NumberFormat factory method using the setters. 690// * 691// * <p>If you want to completely customize a decimal format, using your own 692// * DecimalFormatSymbols (such as group separators) and your own information for 693// * currency plural formatting (such as plural rule and currency plural patterns), you 694// * can use this constructor. 695// * 696// * @param pattern a non-localized pattern string 697// * @param symbols the set of symbols to be used 698// * @param infoInput the information used for currency plural format, including 699// * currency plural patterns and plural rules. 700// * @param style the decimal formatting style, it is one of the following values: 701// * NumberFormat.NUMBERSTYLE; NumberFormat.CURRENCYSTYLE; NumberFormat.PERCENTSTYLE; 702// * NumberFormat.SCIENTIFICSTYLE; NumberFormat.INTEGERSTYLE; 703// * NumberFormat.ISOCURRENCYSTYLE; NumberFormat.PLURALCURRENCYSTYLE; 704// * @stable ICU 4.2 705// */ 706// public DecimalFormat(String pattern, DecimalFormatSymbols symbols, CurrencyPluralInfo infoInput, 707// int style) { 708// throw new UnsupportedOperationException("Constructor not supported by com.ibm.icu.base"); 709// } 710 711 /** 712 * {@inheritDoc} 713 * @stable ICU 2.0 714 */ 715 public StringBuffer format(double number, StringBuffer result, FieldPosition fieldPosition) { 716 return super.format(number, result, fieldPosition); 717 } 718 719 /** 720 * @stable ICU 2.0 721 */ 722 // [Spark/CDL] Delegate to format_long_StringBuffer_FieldPosition_boolean 723 public StringBuffer format(long number, StringBuffer result, FieldPosition fieldPosition) { 724 return super.format(number, result, fieldPosition); 725 } 726 727 /** 728 * Formats a BigInteger number. 729 * 730 * @stable ICU 2.0 731 */ 732 public StringBuffer format(BigInteger number, StringBuffer result, 733 FieldPosition fieldPosition) { 734 return super.format(number, result, fieldPosition); 735 } 736 737 /** 738 * Formats a BigDecimal number. 739 * 740 * @stable ICU 2.0 741 */ 742 public StringBuffer format(java.math.BigDecimal number, StringBuffer result, 743 FieldPosition fieldPosition) { 744 return super.format(number, result, fieldPosition); 745 } 746 747 /** 748 * Formats a BigDecimal number. 749 * 750 * @stable ICU 2.0 751 */ 752 public StringBuffer format(BigDecimal number, StringBuffer result, 753 FieldPosition fieldPosition) { 754 return super.format(number, result, fieldPosition); 755 } 756 757 /** 758 * Parses the given string, returning a <code>Number</code> object to represent the 759 * parsed value. <code>Double</code> objects are returned to represent non-integral 760 * values which cannot be stored in a <code>BigDecimal</code>. These are 761 * <code>NaN</code>, infinity, -infinity, and -0.0. If {@link #isParseBigDecimal()} is 762 * false (the default), all other values are returned as <code>Long</code>, 763 * <code>BigInteger</code>, or <code>BigDecimal</code> values, in that order of 764 * preference. If {@link #isParseBigDecimal()} is true, all other values are returned 765 * as <code>BigDecimal</code> valuse. If the parse fails, null is returned. 766 * 767 * @param text the string to be parsed 768 * @param parsePosition defines the position where parsing is to begin, and upon 769 * return, the position where parsing left off. If the position has not changed upon 770 * return, then parsing failed. 771 * @return a <code>Number</code> object with the parsed value or 772 * <code>null</code> if the parse failed 773 * @stable ICU 2.0 774 */ 775 public Number parse(String text, ParsePosition parsePosition) { 776 return super.parse(text, parsePosition); 777 } 778 779// /** 780// * Parses text from the given string as a CurrencyAmount. Unlike the parse() method, 781// * this method will attempt to parse a generic currency name, searching for a match of 782// * this object's locale's currency display names, or for a 3-letter ISO currency 783// * code. This method will fail if this format is not a currency format, that is, if it 784// * does not contain the currency pattern symbol (U+00A4) in its prefix or suffix. 785// * 786// * @param text the string to parse 787// * @param pos input-output position; on input, the position within text to match; must 788// * have 0 <= pos.getIndex() < text.length(); on output, the position after the last 789// * matched character. If the parse fails, the position in unchanged upon output. 790// * @return a CurrencyAmount, or null upon failure 791// */ 792// CurrencyAmount parseCurrency(String text, ParsePosition pos) { 793// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 794// } 795 796 /** 797 * Returns a copy of the decimal format symbols used by this format. 798 * 799 * @return desired DecimalFormatSymbols 800 * @see DecimalFormatSymbols 801 * @stable ICU 2.0 802 */ 803 public DecimalFormatSymbols getDecimalFormatSymbols() { 804 return new DecimalFormatSymbols(((java.text.DecimalFormat)numberFormat).getDecimalFormatSymbols()); 805 } 806 807 /** 808 * Sets the decimal format symbols used by this format. The format uses a copy of the 809 * provided symbols. 810 * 811 * @param newSymbols desired DecimalFormatSymbols 812 * @see DecimalFormatSymbols 813 * @stable ICU 2.0 814 */ 815 public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols) { 816 ((java.text.DecimalFormat)numberFormat).setDecimalFormatSymbols(newSymbols.dfs); 817 } 818 819 /** 820 * Returns the positive prefix. 821 * 822 * <p>Examples: +123, $123, sFr123 823 * @return the prefix 824 * @stable ICU 2.0 825 */ 826 public String getPositivePrefix() { 827 return ((java.text.DecimalFormat)numberFormat).getPositivePrefix(); 828 } 829 830 /** 831 * Sets the positive prefix. 832 * 833 * <p>Examples: +123, $123, sFr123 834 * @param newValue the prefix 835 * @stable ICU 2.0 836 */ 837 public void setPositivePrefix(String newValue) { 838 ((java.text.DecimalFormat)numberFormat).setPositivePrefix(newValue); 839 } 840 841 /** 842 * Returns the negative prefix. 843 * 844 * <p>Examples: -123, ($123) (with negative suffix), sFr-123 845 * 846 * @return the prefix 847 * @stable ICU 2.0 848 */ 849 public String getNegativePrefix() { 850 return ((java.text.DecimalFormat)numberFormat).getNegativePrefix(); 851 } 852 853 /** 854 * Sets the negative prefix. 855 * 856 * <p>Examples: -123, ($123) (with negative suffix), sFr-123 857 * @param newValue the prefix 858 * @stable ICU 2.0 859 */ 860 public void setNegativePrefix(String newValue) { 861 ((java.text.DecimalFormat)numberFormat).setNegativePrefix(newValue); 862 } 863 864 /** 865 * Returns the positive suffix. 866 * 867 * <p>Example: 123% 868 * 869 * @return the suffix 870 * @stable ICU 2.0 871 */ 872 public String getPositiveSuffix() { 873 return ((java.text.DecimalFormat)numberFormat).getPositiveSuffix(); 874 } 875 876 /** 877 * Sets the positive suffix. 878 * 879 * <p>Example: 123% 880 * @param newValue the suffix 881 * @stable ICU 2.0 882 */ 883 public void setPositiveSuffix(String newValue) { 884 ((java.text.DecimalFormat)numberFormat).setPositiveSuffix(newValue); 885 } 886 887 /** 888 * Returns the negative suffix. 889 * 890 * <p>Examples: -123%, ($123) (with positive suffixes) 891 * 892 * @return the suffix 893 * @stable ICU 2.0 894 */ 895 public String getNegativeSuffix() { 896 return ((java.text.DecimalFormat)numberFormat).getNegativeSuffix(); 897 } 898 899 /** 900 * Sets the positive suffix. 901 * 902 * <p>Examples: 123% 903 * @param newValue the suffix 904 * @stable ICU 2.0 905 */ 906 public void setNegativeSuffix(String newValue) { 907 ((java.text.DecimalFormat)numberFormat).setNegativeSuffix(newValue); 908 } 909 910 /** 911 * Returns the multiplier for use in percent, permill, etc. For a percentage, set the 912 * suffixes to have "%" and the multiplier to be 100. (For Arabic, use arabic percent 913 * symbol). For a permill, set the suffixes to have "\u2031" and the multiplier to be 914 * 1000. 915 * 916 * <p>Examples: with 100, 1.23 -> "123", and "123" -> 1.23 917 * 918 * @return the multiplier 919 * @stable ICU 2.0 920 */ 921 public int getMultiplier() { 922 return ((java.text.DecimalFormat)numberFormat).getMultiplier(); 923 } 924 925 /** 926 * Sets the multiplier for use in percent, permill, etc. For a percentage, set the 927 * suffixes to have "%" and the multiplier to be 100. (For Arabic, use arabic percent 928 * symbol). For a permill, set the suffixes to have "\u2031" and the multiplier to be 929 * 1000. 930 * 931 * <p>Examples: with 100, 1.23 -> "123", and "123" -> 1.23 932 * 933 * @param newValue the multiplier 934 * @stable ICU 2.0 935 */ 936 public void setMultiplier(int newValue) { 937 ((java.text.DecimalFormat)numberFormat).setMultiplier(newValue); 938 } 939 940// /** 941// * {@icu} Returns the rounding increment. 942// * 943// * @return A positive rounding increment, or <code>null</code> if rounding is not in 944// * effect. 945// * @see #setRoundingIncrement 946// * @see #getRoundingMode 947// * @see #setRoundingMode 948// * @stable ICU 2.0 949// */ 950// public BigDecimal getRoundingIncrement() { 951// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 952// } 953 954// /** 955// * {@icu} Sets the rounding increment. This method also controls whether rounding is 956// * enabled. 957// * 958// * @param newValue A positive rounding increment, or <code>null</code> or 959// * <code>BigDecimal(0.0)</code> to disable rounding. 960// * @throws IllegalArgumentException if <code>newValue</code> is < 0.0 961// * @see #getRoundingIncrement 962// * @see #getRoundingMode 963// * @see #setRoundingMode 964// * @stable ICU 2.0 965// */ 966// public void setRoundingIncrement(java.math.BigDecimal newValue) { 967// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 968// } 969 970// /** 971// * {@icu} Sets the rounding increment. This method also controls whether rounding is 972// * enabled. 973// * 974// * @param newValue A positive rounding increment, or <code>null</code> or 975// * <code>BigDecimal(0.0)</code> to disable rounding. 976// * @throws IllegalArgumentException if <code>newValue</code> is < 0.0 977// * @see #getRoundingIncrement 978// * @see #getRoundingMode 979// * @see #setRoundingMode 980// * @stable ICU 3.6 981// */ 982// public void setRoundingIncrement(BigDecimal newValue) { 983// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 984// } 985 986// /** 987// * {@icu} Sets the rounding increment. This method also controls whether rounding is 988// * enabled. 989// * 990// * @param newValue A positive rounding increment, or 0.0 to disable rounding. 991// * @throws IllegalArgumentException if <code>newValue</code> is < 0.0 992// * @see #getRoundingIncrement 993// * @see #getRoundingMode 994// * @see #setRoundingMode 995// * @stable ICU 2.0 996// */ 997// public void setRoundingIncrement(double newValue) { 998// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 999// } 1000 1001// /** 1002// * Returns the rounding mode. 1003// * 1004// * @return A rounding mode, between <code>BigDecimal.ROUND_UP</code> and 1005// * <code>BigDecimal.ROUND_UNNECESSARY</code>. 1006// * @see #setRoundingIncrement 1007// * @see #getRoundingIncrement 1008// * @see #setRoundingMode 1009// * @see java.math.BigDecimal 1010// * @stable ICU 2.0 1011// */ 1012// public int getRoundingMode() { 1013// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1014// } 1015 1016// /** 1017// * Sets the rounding mode. This has no effect unless the rounding increment is greater 1018// * than zero. 1019// * 1020// * @param roundingMode A rounding mode, between <code>BigDecimal.ROUND_UP</code> and 1021// * <code>BigDecimal.ROUND_UNNECESSARY</code>. 1022// * @exception IllegalArgumentException if <code>roundingMode</code> is unrecognized. 1023// * @see #setRoundingIncrement 1024// * @see #getRoundingIncrement 1025// * @see #getRoundingMode 1026// * @see java.math.BigDecimal 1027// * @stable ICU 2.0 1028// */ 1029// public void setRoundingMode(int roundingMode) { 1030// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1031// } 1032 1033// /** 1034// * Returns the width to which the output of <code>format()</code> is padded. The width is 1035// * counted in 16-bit code units. 1036// * 1037// * @return the format width, or zero if no padding is in effect 1038// * @see #setFormatWidth 1039// * @see #getPadCharacter 1040// * @see #setPadCharacter 1041// * @see #getPadPosition 1042// * @see #setPadPosition 1043// * @stable ICU 2.0 1044// */ 1045// public int getFormatWidth() { 1046// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1047// } 1048 1049// /** 1050// * Sets the width to which the output of <code>format()</code> is 1051// * padded. The width is counted in 16-bit code units. This method 1052// * also controls whether padding is enabled. 1053// * 1054// * @param width the width to which to pad the result of 1055// * <code>format()</code>, or zero to disable padding 1056// * @exception IllegalArgumentException if <code>width</code> is < 0 1057// * @see #getFormatWidth 1058// * @see #getPadCharacter 1059// * @see #setPadCharacter 1060// * @see #getPadPosition 1061// * @see #setPadPosition 1062// * @stable ICU 2.0 1063// */ 1064// public void setFormatWidth(int width) { 1065// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1066// } 1067 1068// /** 1069// * {@icu} Returns the character used to pad to the format width. The default is ' '. 1070// * 1071// * @return the pad character 1072// * @see #setFormatWidth 1073// * @see #getFormatWidth 1074// * @see #setPadCharacter 1075// * @see #getPadPosition 1076// * @see #setPadPosition 1077// * @stable ICU 2.0 1078// */ 1079// public char getPadCharacter() { 1080// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1081// } 1082 1083// /** 1084// * {@icu} Sets the character used to pad to the format width. If padding is not 1085// * enabled, then this will take effect if padding is later enabled. 1086// * 1087// * @param padChar the pad character 1088// * @see #setFormatWidth 1089// * @see #getFormatWidth 1090// * @see #getPadCharacter 1091// * @see #getPadPosition 1092// * @see #setPadPosition 1093// * @stable ICU 2.0 1094// */ 1095// public void setPadCharacter(char padChar) { 1096// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1097// } 1098 1099// /** 1100// * {@icu} Returns the position at which padding will take place. This is the location at 1101// * which padding will be inserted if the result of <code>format()</code> is shorter 1102// * than the format width. 1103// * 1104// * @return the pad position, one of <code>PAD_BEFORE_PREFIX</code>, 1105// * <code>PAD_AFTER_PREFIX</code>, <code>PAD_BEFORE_SUFFIX</code>, or 1106// * <code>PAD_AFTER_SUFFIX</code>. 1107// * @see #setFormatWidth 1108// * @see #getFormatWidth 1109// * @see #setPadCharacter 1110// * @see #getPadCharacter 1111// * @see #setPadPosition 1112// * @see #PAD_BEFORE_PREFIX 1113// * @see #PAD_AFTER_PREFIX 1114// * @see #PAD_BEFORE_SUFFIX 1115// * @see #PAD_AFTER_SUFFIX 1116// * @stable ICU 2.0 1117// */ 1118// public int getPadPosition() { 1119// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1120// } 1121 1122// /** 1123// * {@icu} Sets the position at which padding will take place. This is the location at 1124// * which padding will be inserted if the result of <code>format()</code> is shorter 1125// * than the format width. This has no effect unless padding is enabled. 1126// * 1127// * @param padPos the pad position, one of <code>PAD_BEFORE_PREFIX</code>, 1128// * <code>PAD_AFTER_PREFIX</code>, <code>PAD_BEFORE_SUFFIX</code>, or 1129// * <code>PAD_AFTER_SUFFIX</code>. 1130// * @exception IllegalArgumentException if the pad position in unrecognized 1131// * @see #setFormatWidth 1132// * @see #getFormatWidth 1133// * @see #setPadCharacter 1134// * @see #getPadCharacter 1135// * @see #getPadPosition 1136// * @see #PAD_BEFORE_PREFIX 1137// * @see #PAD_AFTER_PREFIX 1138// * @see #PAD_BEFORE_SUFFIX 1139// * @see #PAD_AFTER_SUFFIX 1140// * @stable ICU 2.0 1141// */ 1142// public void setPadPosition(int padPos) { 1143// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1144// } 1145 1146// /** 1147// * {@icu} Returns whether or not scientific notation is used. 1148// * 1149// * @return true if this object formats and parses scientific notation 1150// * @see #setScientificNotation 1151// * @see #getMinimumExponentDigits 1152// * @see #setMinimumExponentDigits 1153// * @see #isExponentSignAlwaysShown 1154// * @see #setExponentSignAlwaysShown 1155// * @stable ICU 2.0 1156// */ 1157// public boolean isScientificNotation() { 1158// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1159// } 1160 1161// /** 1162// * {@icu} Sets whether or not scientific notation is used. When scientific notation is 1163// * used, the effective maximum number of integer digits is <= 8. If the maximum number 1164// * of integer digits is set to more than 8, the effective maximum will be 1. This 1165// * allows this call to generate a 'default' scientific number format without 1166// * additional changes. 1167// * 1168// * @param useScientific true if this object formats and parses scientific notation 1169// * @see #isScientificNotation 1170// * @see #getMinimumExponentDigits 1171// * @see #setMinimumExponentDigits 1172// * @see #isExponentSignAlwaysShown 1173// * @see #setExponentSignAlwaysShown 1174// * @stable ICU 2.0 1175// */ 1176// public void setScientificNotation(boolean useScientific) { 1177// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1178// } 1179 1180// /** 1181// * {@icu} Returns the minimum exponent digits that will be shown. 1182// * 1183// * @return the minimum exponent digits that will be shown 1184// * @see #setScientificNotation 1185// * @see #isScientificNotation 1186// * @see #setMinimumExponentDigits 1187// * @see #isExponentSignAlwaysShown 1188// * @see #setExponentSignAlwaysShown 1189// * @stable ICU 2.0 1190// */ 1191// public byte getMinimumExponentDigits() { 1192// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1193// } 1194 1195// /** 1196// * {@icu} Sets the minimum exponent digits that will be shown. This has no effect 1197// * unless scientific notation is in use. 1198// * 1199// * @param minExpDig a value >= 1 indicating the fewest exponent 1200// * digits that will be shown 1201// * @exception IllegalArgumentException if <code>minExpDig</code> < 1 1202// * @see #setScientificNotation 1203// * @see #isScientificNotation 1204// * @see #getMinimumExponentDigits 1205// * @see #isExponentSignAlwaysShown 1206// * @see #setExponentSignAlwaysShown 1207// * @stable ICU 2.0 1208// */ 1209// public void setMinimumExponentDigits(byte minExpDig) { 1210// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1211// } 1212 1213// /** 1214// * {@icu} Returns whether the exponent sign is always shown. 1215// * 1216// * @return true if the exponent is always prefixed with either the localized minus 1217// * sign or the localized plus sign, false if only negative exponents are prefixed with 1218// * the localized minus sign. 1219// * @see #setScientificNotation 1220// * @see #isScientificNotation 1221// * @see #setMinimumExponentDigits 1222// * @see #getMinimumExponentDigits 1223// * @see #setExponentSignAlwaysShown 1224// * @stable ICU 2.0 1225// */ 1226// public boolean isExponentSignAlwaysShown() { 1227// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1228// } 1229 1230// /** 1231// * {@icu} Sets whether the exponent sign is always shown. This has no effect unless 1232// * scientific notation is in use. 1233// * 1234// * @param expSignAlways true if the exponent is always prefixed with either the 1235// * localized minus sign or the localized plus sign, false if only negative exponents 1236// * are prefixed with the localized minus sign. 1237// * @see #setScientificNotation 1238// * @see #isScientificNotation 1239// * @see #setMinimumExponentDigits 1240// * @see #getMinimumExponentDigits 1241// * @see #isExponentSignAlwaysShown 1242// * @stable ICU 2.0 1243// */ 1244// public void setExponentSignAlwaysShown(boolean expSignAlways) { 1245// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1246// } 1247 1248 /** 1249 * Returns the grouping size. Grouping size is the number of digits between grouping 1250 * separators in the integer portion of a number. For example, in the number 1251 * "123,456.78", the grouping size is 3. 1252 * 1253 * @see #setGroupingSize 1254 * @see NumberFormat#isGroupingUsed 1255 * @see DecimalFormatSymbols#getGroupingSeparator 1256 * @stable ICU 2.0 1257 */ 1258 public int getGroupingSize() { 1259 return ((java.text.DecimalFormat)numberFormat).getGroupingSize(); 1260 } 1261 1262 /** 1263 * Sets the grouping size. Grouping size is the number of digits between grouping 1264 * separators in the integer portion of a number. For example, in the number 1265 * "123,456.78", the grouping size is 3. 1266 * 1267 * @see #getGroupingSize 1268 * @see NumberFormat#setGroupingUsed 1269 * @see DecimalFormatSymbols#setGroupingSeparator 1270 * @stable ICU 2.0 1271 */ 1272 public void setGroupingSize(int newValue) { 1273 ((java.text.DecimalFormat)numberFormat).setGroupingSize(newValue); 1274 } 1275 1276// /** 1277// * {@icu} Returns the secondary grouping size. In some locales one grouping interval 1278// * is used for the least significant integer digits (the primary grouping size), and 1279// * another is used for all others (the secondary grouping size). A formatter 1280// * supporting a secondary grouping size will return a positive integer unequal to the 1281// * primary grouping size returned by <code>getGroupingSize()</code>. For example, if 1282// * the primary grouping size is 4, and the secondary grouping size is 2, then the 1283// * number 123456789 formats as "1,23,45,6789", and the pattern appears as "#,##,###0". 1284// * 1285// * @return the secondary grouping size, or a value less than one if there is none 1286// * @see #setSecondaryGroupingSize 1287// * @see NumberFormat#isGroupingUsed 1288// * @see DecimalFormatSymbols#getGroupingSeparator 1289// * @stable ICU 2.0 1290// */ 1291// public int getSecondaryGroupingSize() { 1292// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1293// } 1294 1295// /** 1296// * {@icu} Sets the secondary grouping size. If set to a value less than 1, then 1297// * secondary grouping is turned off, and the primary grouping size is used for all 1298// * intervals, not just the least significant. 1299// * 1300// * @see #getSecondaryGroupingSize 1301// * @see NumberFormat#setGroupingUsed 1302// * @see DecimalFormatSymbols#setGroupingSeparator 1303// * @stable ICU 2.0 1304// */ 1305// public void setSecondaryGroupingSize(int newValue) { 1306// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1307// } 1308 1309// /** 1310// * {@icu} Returns the MathContext used by this format. 1311// * 1312// * @return desired MathContext 1313// * @see #getMathContext 1314// * @stable ICU 4.2 1315// */ 1316// public MathContext getMathContextICU() { 1317// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1318// } 1319 1320// /** 1321// * {@icu} Returns the MathContext used by this format. 1322// * 1323// * @return desired MathContext 1324// * @see #getMathContext 1325// * @stable ICU 4.2 1326// */ 1327// public java.math.MathContext getMathContext() { 1328// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1329// } 1330 1331// /** 1332// * {@icu} Sets the MathContext used by this format. 1333// * 1334// * @param newValue desired MathContext 1335// * @see #getMathContext 1336// * @stable ICU 4.2 1337// */ 1338// public void setMathContextICU(MathContext newValue) { 1339// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1340// } 1341 1342// /** 1343// * {@icu} Sets the MathContext used by this format. 1344// * 1345// * @param newValue desired MathContext 1346// * @see #getMathContext 1347// * @stable ICU 4.2 1348// */ 1349// public void setMathContext(java.math.MathContext newValue) { 1350// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1351// } 1352 1353 /** 1354 * Returns the behavior of the decimal separator with integers. (The decimal 1355 * separator will always appear with decimals.) <p> Example: Decimal ON: 12345 -> 1356 * 12345.; OFF: 12345 -> 12345 1357 * 1358 * @stable ICU 2.0 1359 */ 1360 public boolean isDecimalSeparatorAlwaysShown() { 1361 return ((java.text.DecimalFormat)numberFormat).isDecimalSeparatorAlwaysShown(); 1362 } 1363 1364 /** 1365 * Sets the behavior of the decimal separator with integers. (The decimal separator 1366 * will always appear with decimals.) 1367 * 1368 * <p>This only affects formatting, and only where there might be no digits after the 1369 * decimal point, e.g., if true, 3456.00 -> "3,456." if false, 3456.00 -> "3456" This 1370 * is independent of parsing. If you want parsing to stop at the decimal point, use 1371 * setParseIntegerOnly. 1372 * 1373 * <p> 1374 * Example: Decimal ON: 12345 -> 12345.; OFF: 12345 -> 12345 1375 * 1376 * @stable ICU 2.0 1377 */ 1378 public void setDecimalSeparatorAlwaysShown(boolean newValue) { 1379 ((java.text.DecimalFormat)numberFormat).setDecimalSeparatorAlwaysShown(newValue); 1380 } 1381 1382// /** 1383// * {@icu} Returns a copy of the CurrencyPluralInfo used by this format. It might 1384// * return null if the decimal format is not a plural type currency decimal 1385// * format. Plural type currency decimal format means either the pattern in the decimal 1386// * format contains 3 currency signs, or the decimal format is initialized with 1387// * PLURALCURRENCYSTYLE. 1388// * 1389// * @return desired CurrencyPluralInfo 1390// * @see CurrencyPluralInfo 1391// * @stable ICU 4.2 1392// */ 1393// public CurrencyPluralInfo getCurrencyPluralInfo() { 1394// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1395// } 1396 1397// /** 1398// * {@icu} Sets the CurrencyPluralInfo used by this format. The format uses a copy of 1399// * the provided information. 1400// * 1401// * @param newInfo desired CurrencyPluralInfo 1402// * @see CurrencyPluralInfo 1403// * @stable ICU 4.2 1404// */ 1405// public void setCurrencyPluralInfo(CurrencyPluralInfo newInfo) { 1406// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1407// } 1408 1409 /** 1410 * Overrides clone. 1411 * @stable ICU 2.0 1412 */ 1413 public Object clone() { 1414 return new DecimalFormatSymbols((java.text.DecimalFormatSymbols)numberFormat.clone()); 1415 } 1416 1417 /** 1418 * Overrides equals. 1419 * @stable ICU 2.0 1420 */ 1421 public boolean equals(Object obj) { 1422 return super.equals(obj); 1423 } 1424 1425 /** 1426 * Overrides hashCode. 1427 * @stable ICU 2.0 1428 */ 1429 public int hashCode() { 1430 return super.hashCode(); 1431 } 1432 1433 /** 1434 * Synthesizes a pattern string that represents the current state of this Format 1435 * object. 1436 * 1437 * @see #applyPattern 1438 * @stable ICU 2.0 1439 */ 1440 public String toPattern() { 1441 return ((java.text.DecimalFormat)numberFormat).toPattern(); 1442 } 1443 1444 /** 1445 * Synthesizes a localized pattern string that represents the current state of this 1446 * Format object. 1447 * 1448 * @see #applyPattern 1449 * @stable ICU 2.0 1450 */ 1451 public String toLocalizedPattern() { 1452 return ((java.text.DecimalFormat)numberFormat).toLocalizedPattern(); 1453 } 1454 1455 /** 1456 * Formats the object to an attributed string, and return the corresponding iterator. 1457 * 1458 * @stable ICU 3.6 1459 */ 1460 public AttributedCharacterIterator formatToCharacterIterator(Object obj) { 1461 AttributedCharacterIterator it = numberFormat.formatToCharacterIterator(obj); 1462 1463 // Extract formatted String first 1464 StringBuilder sb = new StringBuilder(); 1465 for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) { 1466 sb.append(c); 1467 } 1468 1469 // Create AttributedString 1470 AttributedString attrstr = new AttributedString(sb.toString()); 1471 1472 // Map JDK Field to ICU Field 1473 int idx = 0; 1474 it.first(); 1475 while (idx < it.getEndIndex()) { 1476 int end = it.getRunLimit(); 1477 Map<Attribute, Object> attributes = it.getAttributes(); 1478 if (attributes != null) { 1479 for (Entry<Attribute, Object> entry : attributes.entrySet()) { 1480 Attribute attr = entry.getKey(); 1481 Object val = entry.getValue(); 1482 if (attr.equals(java.text.NumberFormat.Field.CURRENCY)) { 1483 val = attr = Field.CURRENCY; 1484 } else if (attr.equals(java.text.NumberFormat.Field.DECIMAL_SEPARATOR)) { 1485 val = attr = Field.DECIMAL_SEPARATOR; 1486 } else if (attr.equals(java.text.NumberFormat.Field.EXPONENT)) { 1487 val = attr = Field.EXPONENT; 1488 } else if (attr.equals(java.text.NumberFormat.Field.EXPONENT_SIGN)) { 1489 val = attr = Field.EXPONENT_SIGN; 1490 } else if (attr.equals(java.text.NumberFormat.Field.EXPONENT_SYMBOL)) { 1491 val = attr = Field.EXPONENT_SYMBOL; 1492 } else if (attr.equals(java.text.NumberFormat.Field.FRACTION)) { 1493 val = attr = Field.FRACTION; 1494 } else if (attr.equals(java.text.NumberFormat.Field.GROUPING_SEPARATOR)) { 1495 val = attr = Field.GROUPING_SEPARATOR; 1496 } else if (attr.equals(java.text.NumberFormat.Field.INTEGER)) { 1497 val = attr = Field.INTEGER; 1498 } else if (attr.equals(java.text.NumberFormat.Field.PERCENT)) { 1499 val = attr = Field.PERCENT; 1500 } else if (attr.equals(java.text.NumberFormat.Field.PERMILLE)) { 1501 val = attr = Field.PERMILLE; 1502 } else if (attr.equals(java.text.NumberFormat.Field.SIGN)) { 1503 val = attr = Field.SIGN; 1504 } 1505 attrstr.addAttribute(attr, val, idx, end); 1506 } 1507 } 1508 idx = end; 1509 while (it.getIndex() < idx) { 1510 it.next(); 1511 } 1512 } 1513 1514 return attrstr.getIterator(); 1515 } 1516 1517 /** 1518 * Applies the given pattern to this Format object. A pattern is a short-hand 1519 * specification for the various formatting properties. These properties can also be 1520 * changed individually through the various setter methods. 1521 * 1522 * <p>There is no limit to integer digits are set by this routine, since that is the 1523 * typical end-user desire; use setMaximumInteger if you want to set a real value. For 1524 * negative numbers, use a second pattern, separated by a semicolon 1525 * 1526 * <p>Example "#,#00.0#" -> 1,234.56 1527 * 1528 * <p>This means a minimum of 2 integer digits, 1 fraction digit, and a maximum of 2 1529 * fraction digits. 1530 * 1531 * <p>Example: "#,#00.0#;(#,#00.0#)" for negatives in parentheses. 1532 * 1533 * <p>In negative patterns, the minimum and maximum counts are ignored; these are 1534 * presumed to be set in the positive pattern. 1535 * 1536 * @stable ICU 2.0 1537 */ 1538 public void applyPattern(String pattern) { 1539 ((java.text.DecimalFormat)numberFormat).applyPattern(pattern); 1540 } 1541 1542 /** 1543 * Applies the given pattern to this Format object. The pattern is assumed to be in a 1544 * localized notation. A pattern is a short-hand specification for the various 1545 * formatting properties. These properties can also be changed individually through 1546 * the various setter methods. 1547 * 1548 * <p>There is no limit to integer digits are set by this routine, since that is the 1549 * typical end-user desire; use setMaximumInteger if you want to set a real value. For 1550 * negative numbers, use a second pattern, separated by a semicolon 1551 * 1552 * <p>Example "#,#00.0#" -> 1,234.56 1553 * 1554 * <p>This means a minimum of 2 integer digits, 1 fraction digit, and a maximum of 2 1555 * fraction digits. 1556 * 1557 * <p>Example: "#,#00.0#;(#,#00.0#)" for negatives in parantheses. 1558 * 1559 * <p>In negative patterns, the minimum and maximum counts are ignored; these are 1560 * presumed to be set in the positive pattern. 1561 * 1562 * @stable ICU 2.0 1563 */ 1564 public void applyLocalizedPattern(String pattern) { 1565 ((java.text.DecimalFormat)numberFormat).applyLocalizedPattern(pattern); 1566 } 1567 1568 /** 1569 * Sets the maximum number of digits allowed in the integer portion of a number. This 1570 * override limits the integer digit count to 309. 1571 * 1572 * @see NumberFormat#setMaximumIntegerDigits 1573 * @stable ICU 2.0 1574 */ 1575 public void setMaximumIntegerDigits(int newValue) { 1576 super.setMaximumIntegerDigits(newValue); 1577 } 1578 1579 /** 1580 * Sets the minimum number of digits allowed in the integer portion of a number. This 1581 * override limits the integer digit count to 309. 1582 * 1583 * @see NumberFormat#setMinimumIntegerDigits 1584 * @stable ICU 2.0 1585 */ 1586 public void setMinimumIntegerDigits(int newValue) { 1587 super.setMinimumIntegerDigits(newValue); 1588 } 1589 1590// /** 1591// * {@icu} Returns the minimum number of significant digits that will be 1592// * displayed. This value has no effect unless {@link #areSignificantDigitsUsed()} 1593// * returns true. 1594// * 1595// * @return the fewest significant digits that will be shown 1596// * @stable ICU 3.0 1597// */ 1598// public int getMinimumSignificantDigits() { 1599// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1600// } 1601 1602// /** 1603// * {@icu} Returns the maximum number of significant digits that will be 1604// * displayed. This value has no effect unless {@link #areSignificantDigitsUsed()} 1605// * returns true. 1606// * 1607// * @return the most significant digits that will be shown 1608// * @stable ICU 3.0 1609// */ 1610// public int getMaximumSignificantDigits() { 1611// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1612// } 1613 1614// /** 1615// * {@icu} Sets the minimum number of significant digits that will be displayed. If 1616// * <code>min</code> is less than one then it is set to one. If the maximum significant 1617// * digits count is less than <code>min</code>, then it is set to 1618// * <code>min</code>. This value has no effect unless {@link #areSignificantDigitsUsed()} 1619// * returns true. 1620// * 1621// * @param min the fewest significant digits to be shown 1622// * @stable ICU 3.0 1623// */ 1624// public void setMinimumSignificantDigits(int min) { 1625// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1626// } 1627 1628// /** 1629// * {@icu} Sets the maximum number of significant digits that will be displayed. If 1630// * <code>max</code> is less than one then it is set to one. If the minimum significant 1631// * digits count is greater than <code>max</code>, then it is set to 1632// * <code>max</code>. This value has no effect unless {@link #areSignificantDigitsUsed()} 1633// * returns true. 1634// * 1635// * @param max the most significant digits to be shown 1636// * @stable ICU 3.0 1637// */ 1638// public void setMaximumSignificantDigits(int max) { 1639// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1640// } 1641 1642// /** 1643// * {@icu} Returns true if significant digits are in use or false if integer and 1644// * fraction digit counts are in use. 1645// * 1646// * @return true if significant digits are in use 1647// * @stable ICU 3.0 1648// */ 1649// public boolean areSignificantDigitsUsed() { 1650// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1651// } 1652 1653// /** 1654// * {@icu} Sets whether significant digits are in use, or integer and fraction digit 1655// * counts are in use. 1656// * 1657// * @param useSignificantDigits true to use significant digits, or false to use integer 1658// * and fraction digit counts 1659// * @stable ICU 3.0 1660// */ 1661// public void setSignificantDigitsUsed(boolean useSignificantDigits) { 1662// throw new UnsupportedOperationException("Method not supported by com.ibm.icu.base"); 1663// } 1664 1665 /** 1666 * Sets the <tt>Currency</tt> object used to display currency amounts. This takes 1667 * effect immediately, if this format is a currency format. If this format is not a 1668 * currency format, then the currency object is used if and when this object becomes a 1669 * currency format through the application of a new pattern. 1670 * 1671 * @param theCurrency new currency object to use. Must not be null. 1672 * @stable ICU 2.2 1673 */ 1674 public void setCurrency(Currency theCurrency) { 1675 super.setCurrency(theCurrency); 1676 } 1677 1678 /** 1679 * Sets the maximum number of digits allowed in the fraction portion of a number. This 1680 * override limits the fraction digit count to 340. 1681 * 1682 * @see NumberFormat#setMaximumFractionDigits 1683 * @stable ICU 2.0 1684 */ 1685 public void setMaximumFractionDigits(int newValue) { 1686 super.setMaximumFractionDigits(newValue); 1687 } 1688 1689 /** 1690 * Sets the minimum number of digits allowed in the fraction portion of a number. This 1691 * override limits the fraction digit count to 340. 1692 * 1693 * @see NumberFormat#setMinimumFractionDigits 1694 * @stable ICU 2.0 1695 */ 1696 public void setMinimumFractionDigits(int newValue) { 1697 super.setMinimumFractionDigits(newValue); 1698 } 1699 1700 /** 1701 * Sets whether {@link #parse(String, ParsePosition)} returns BigDecimal. The 1702 * default value is false. 1703 * 1704 * @param value true if {@link #parse(String, ParsePosition)} 1705 * returns BigDecimal. 1706 * @stable ICU 3.6 1707 */ 1708 public void setParseBigDecimal(boolean value) { 1709 ((java.text.DecimalFormat)numberFormat).setParseBigDecimal(value); 1710 } 1711 1712 /** 1713 * Returns whether {@link #parse(String, ParsePosition)} returns BigDecimal. 1714 * 1715 * @return true if {@link #parse(String, ParsePosition)} returns BigDecimal. 1716 * @stable ICU 3.6 1717 */ 1718 public boolean isParseBigDecimal() { 1719 return ((java.text.DecimalFormat)numberFormat).isParseBigDecimal(); 1720 } 1721 1722 // ---------------------------------------------------------------------- 1723 // CONSTANTS 1724 // ---------------------------------------------------------------------- 1725 1726 /** 1727 * {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to 1728 * specify pad characters inserted before the prefix. 1729 * 1730 * @see #setPadPosition 1731 * @see #getPadPosition 1732 * @see #PAD_AFTER_PREFIX 1733 * @see #PAD_BEFORE_SUFFIX 1734 * @see #PAD_AFTER_SUFFIX 1735 * @stable ICU 2.0 1736 */ 1737 public static final int PAD_BEFORE_PREFIX = 0; 1738 1739 /** 1740 * {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to 1741 * specify pad characters inserted after the prefix. 1742 * 1743 * @see #setPadPosition 1744 * @see #getPadPosition 1745 * @see #PAD_BEFORE_PREFIX 1746 * @see #PAD_BEFORE_SUFFIX 1747 * @see #PAD_AFTER_SUFFIX 1748 * @stable ICU 2.0 1749 */ 1750 public static final int PAD_AFTER_PREFIX = 1; 1751 1752 /** 1753 * {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to 1754 * specify pad characters inserted before the suffix. 1755 * 1756 * @see #setPadPosition 1757 * @see #getPadPosition 1758 * @see #PAD_BEFORE_PREFIX 1759 * @see #PAD_AFTER_PREFIX 1760 * @see #PAD_AFTER_SUFFIX 1761 * @stable ICU 2.0 1762 */ 1763 public static final int PAD_BEFORE_SUFFIX = 2; 1764 1765 /** 1766 * {@icu} Constant for {@link #getPadPosition()} and {@link #setPadPosition(int)} to 1767 * specify pad characters inserted after the suffix. 1768 * 1769 * @see #setPadPosition 1770 * @see #getPadPosition 1771 * @see #PAD_BEFORE_PREFIX 1772 * @see #PAD_AFTER_PREFIX 1773 * @see #PAD_BEFORE_SUFFIX 1774 * @stable ICU 2.0 1775 */ 1776 public static final int PAD_AFTER_SUFFIX = 3; 1777} 1778 1779// eof 1780