decimalformat.html

来自「API資料大全」· HTML 代码 · 共 1,215 行 · 第 1/5 页

HTML
1,215
字号
 formatted using the localized minus sign, <em>not</em> the prefix and suffix from the pattern.  This allows patterns such as "0.###E0 m/s". <li>The minimum number of integer digits is achieved by adjusting the exponent.  Example: 0.00123 formatted with "00.###E0" yields "12.3E-4".  This only happens if there is no maximum number of integer digits.  If there is a maximum, then the minimum number of integer digits is fixed at one. <li>The maximum number of integer digits, if present, forces the exponent to be a multiple of that number.  The most common use of this is to generate <em>engineering notation</em>, in which the exponent is a multiple of three, e.g., "##0.#####E0".  Using this pattern, the number 12345 formats to "12.345E3", and 123456 formats to "123.456E3". <li>The number of significant digits in the mantissa is the sum of the <em>minimum integer</em> and <em>maximum fraction</em> digits, and is unaffected by the maximum integer digits.  For example, 12345 formatted with "##0.##E0" is "12.3E3".  To show all digits, set the significant digits count to zero.  The number of significant digits does not affect parsing. <li>Exponential patterns may not contain grouping separators. </ul> <p><strong>Pattern Syntax</strong> <pre> pattern     := pos_pattern{';' neg_pattern} pos_pattern := {prefix}number{suffix} neg_pattern := {prefix}number{suffix} number      := integer{'.' fraction}{exponent} prefix      := '&#92;u0000'..'&#92;uFFFD' - special_characters suffix      := '&#92;u0000'..'&#92;uFFFD' - special_characters integer     := min_int | '#' | '#' integer | '#' ',' integer min_int     := '0' | '0' min_int | '0' ',' min_int fraction    := '0'* '#'* exponent    := 'E' '0' '0'* &#32; Notation:   X*       0 or more instances of X   { X }    0 or 1 instances of X   X | Y    either X or Y   X..Y     any character from X up to Y, inclusive   S - T    characters in S, except those in T </pre> <p><strong>Special Pattern Characters</strong> <p>Many characters in a pattern are taken literally; they are matched during parsing and output unchanged during formatting.  Special characters, on the other hand, stand for other characters, strings, or classes of characters. They must be quoted, unless noted otherwise, if they are to appear in the prefix or suffix as literals. <p>The characters listed here are used in non-localized patterns.  Localized patterns use the corresponding characters taken from this formatter's <code>DecimalFormatSymbols</code> object instead, and these characters lose their special status.  Two exceptions are the currency sign and quote, which are not localized. <p><table border=1> <tr><th>Symbol<th>Location<th>Localized?<th>Meaning</tr> <tr><td>0<td>Number<td>Y<td>Digit <tr><td>#<td>Number<td>Y<td>Digit, zero shows as absent</tr> <tr><td>.<td>Number<td>Y<td>Decimal separator or monetary decimal separator</tr> <tr><td>-<td>Number<td>Y<td>Minus sign</tr> <tr><td>,<td>Number<td>Y<td>Grouping separator</tr> <tr><td>E<td>Number<td>Y          <td>Separates mantissa and exponent in scientific notation.              <em>Need not be quoted in prefix or suffix.</em></tr> <tr><td>;<td>Subpattern boundary<td>Y          <td>Separates positive and negative subpatterns</tr> <tr><td>%<td>Prefix or suffix<td>Y<td>Multiply by 100 and show as percentage</tr> <tr><td>&#92;u2030<td>Prefix or suffix<td>Y                   <td>Multiply by 1000 and show as per mille</tr> <tr><td>&#164;<br>(&#92;u00A4)<td>Prefix or suffix<td>N                   <td>Currency sign, replaced by currency symbol.  If                   doubled, replaced by international currency symbol.                   If present in a pattern, the monetary decimal separator                   is used instead of the decimal separator.</tr> <tr><td>'<td>Prefix or suffix<td>N          <td>Used to quote special characters in a prefix or suffix,              for example, <code>"'#'#"</code> formats 123 to              <code>"#123"</code>.  To create a single quote              itself, use two in a row: <code>"# o''clock"</code>.</tr> </table> </pre><P><DL><DT><B>See Also: </B><DD><A HREF="../../java/text/Format.html"><CODE>Format</CODE></A>, <A HREF="../../java/text/NumberFormat.html"><CODE>NumberFormat</CODE></A>, <A HREF="../../java/text/ChoiceFormat.html"><CODE>ChoiceFormat</CODE></A>, <A HREF="../../java/text/ParsePosition.html"><CODE>ParsePosition</CODE></A>, <A HREF="../../serialized-form.html#java.text.DecimalFormat">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="fields_inherited_from_class_java.text.NumberFormat"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from class java.text.<A HREF="../../java/text/NumberFormat.html">NumberFormat</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../java/text/NumberFormat.html#FRACTION_FIELD">FRACTION_FIELD</A>, <A HREF="../../java/text/NumberFormat.html#INTEGER_FIELD">INTEGER_FIELD</A></CODE></TD></TR></TABLE>&nbsp;<!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#DecimalFormat()">DecimalFormat</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a DecimalFormat using the default pattern and symbols for the default locale.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#DecimalFormat(java.lang.String)">DecimalFormat</A></B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;pattern)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a DecimalFormat from the given pattern and the symbols for the default locale.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#DecimalFormat(java.lang.String, java.text.DecimalFormatSymbols)">DecimalFormat</A></B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;pattern,              <A HREF="../../java/text/DecimalFormatSymbols.html">DecimalFormatSymbols</A>&nbsp;symbols)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Create a DecimalFormat from the given pattern and symbols.</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#applyLocalizedPattern(java.lang.String)">applyLocalizedPattern</A></B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;pattern)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Apply the given pattern to this Format object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#applyPattern(java.lang.String)">applyPattern</A></B>(<A HREF="../../java/lang/String.html">String</A>&nbsp;pattern)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Apply the given pattern to this Format object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/Object.html">Object</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#clone()">clone</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Standard override; no change in semantics.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#equals(java.lang.Object)">equals</A></B>(<A HREF="../../java/lang/Object.html">Object</A>&nbsp;obj)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Overrides equals</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/StringBuffer.html">StringBuffer</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#format(double, java.lang.StringBuffer, java.text.FieldPosition)">format</A></B>(double&nbsp;number,       <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A>&nbsp;result,       <A HREF="../../java/text/FieldPosition.html">FieldPosition</A>&nbsp;fieldPosition)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Formats a double to produce a string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/StringBuffer.html">StringBuffer</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#format(long, java.lang.StringBuffer, java.text.FieldPosition)">format</A></B>(long&nbsp;number,       <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A>&nbsp;result,       <A HREF="../../java/text/FieldPosition.html">FieldPosition</A>&nbsp;fieldPosition)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Format a long to produce a string.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/text/DecimalFormatSymbols.html">DecimalFormatSymbols</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#getDecimalFormatSymbols()">getDecimalFormatSymbols</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the decimal format symbols, which is generally not changed by the programmer or user.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#getGroupingSize()">getGroupingSize</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return the grouping size.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#getMultiplier()">getMultiplier</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the multiplier for use in percent, permill, etc.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#getNegativePrefix()">getNegativePrefix</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the negative prefix.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../java/lang/String.html">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../java/text/DecimalFormat.html#getNegativeSuffix()">getNegativeSuffix</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Get the negative suffix.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?