decimalformat.html
来自「API資料大全」· HTML 代码 · 共 1,215 行 · 第 1/5 页
HTML
1,215 行
<HR><A NAME="DecimalFormat(java.lang.String, java.text.DecimalFormatSymbols)"><!-- --></A><H3>DecimalFormat</H3><PRE>public <B>DecimalFormat</B>(<A HREF="../../java/lang/String.html">String</A> pattern, <A HREF="../../java/text/DecimalFormatSymbols.html">DecimalFormatSymbols</A> symbols)</PRE><DL><DD>Create a DecimalFormat from the given pattern and symbols. Use this constructor when you need to completely customize the behavior of the format. <p> To obtain standard formats for a given locale, use the factory methods on NumberFormat such as getInstance or getCurrencyInstance. If you need only minor adjustments to a standard format, you can modify the format returned by a NumberFormat factory method.<DD><DL><DT><B>Parameters:</B><DD><CODE>pattern</CODE> - a non-localized pattern string<DD><CODE>symbols</CODE> - the set of symbols to be used<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the given pattern is invalid<DT><B>See Also: </B><DD><A HREF="../../java/text/NumberFormat.html#getInstance()"><CODE>NumberFormat.getInstance()</CODE></A>, <A HREF="../../java/text/NumberFormat.html#getNumberInstance()"><CODE>NumberFormat.getNumberInstance()</CODE></A>, <A HREF="../../java/text/NumberFormat.html#getCurrencyInstance()"><CODE>NumberFormat.getCurrencyInstance()</CODE></A>, <A HREF="../../java/text/NumberFormat.html#getPercentInstance()"><CODE>NumberFormat.getPercentInstance()</CODE></A>, <A HREF="../../java/text/DecimalFormatSymbols.html"><CODE>DecimalFormatSymbols</CODE></A></DL></DD></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="format(double, java.lang.StringBuffer, java.text.FieldPosition)"><!-- --></A><H3>format</H3><PRE>public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>format</B>(double number, <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> result, <A HREF="../../java/text/FieldPosition.html">FieldPosition</A> fieldPosition)</PRE><DL><DD>Formats a double to produce a string.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/text/NumberFormat.html#format(double, java.lang.StringBuffer, java.text.FieldPosition)">format</A></CODE> in class <CODE><A HREF="../../java/text/NumberFormat.html">NumberFormat</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>number</CODE> - The double to format<DD><CODE>toAppendTo</CODE> - where the text is to be appended<DD><CODE>fieldPosition</CODE> - On input: an alignment field, if desired. On output: the offsets of the alignment field.<DT><B>Returns:</B><DD>The value passed in as the result parameter<DT><B>See Also: </B><DD><A HREF="../../java/text/FieldPosition.html"><CODE>FieldPosition</CODE></A></DL></DD></DL><HR><A NAME="format(long, java.lang.StringBuffer, java.text.FieldPosition)"><!-- --></A><H3>format</H3><PRE>public <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> <B>format</B>(long number, <A HREF="../../java/lang/StringBuffer.html">StringBuffer</A> result, <A HREF="../../java/text/FieldPosition.html">FieldPosition</A> fieldPosition)</PRE><DL><DD>Format a long to produce a string.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/text/NumberFormat.html#format(long, java.lang.StringBuffer, java.text.FieldPosition)">format</A></CODE> in class <CODE><A HREF="../../java/text/NumberFormat.html">NumberFormat</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>number</CODE> - The long to format<DD><CODE>toAppendTo</CODE> - where the text is to be appended<DD><CODE>fieldPosition</CODE> - On input: an alignment field, if desired. On output: the offsets of the alignment field.<DT><B>Returns:</B><DD>The value passed in as the result parameter<DT><B>See Also: </B><DD><A HREF="../../java/text/FieldPosition.html"><CODE>FieldPosition</CODE></A></DL></DD></DL><HR><A NAME="parse(java.lang.String, java.text.ParsePosition)"><!-- --></A><H3>parse</H3><PRE>public <A HREF="../../java/lang/Number.html">Number</A> <B>parse</B>(<A HREF="../../java/lang/String.html">String</A> text, <A HREF="../../java/text/ParsePosition.html">ParsePosition</A> parsePosition)</PRE><DL><DD>Returns an instance of <code>Number</code> with a value matching the given string. The most economical subclass that can represent all the bits of the source string is chosen.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/text/NumberFormat.html#parse(java.lang.String, java.text.ParsePosition)">parse</A></CODE> in class <CODE><A HREF="../../java/text/NumberFormat.html">NumberFormat</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>text</CODE> - the string to be parsed<DD><CODE>parsePosition</CODE> - on entry, where to begin parsing; on exit, just past the last parsed character. If parsing fails, the index will not move and the error index will be set.<DT><B>Returns:</B><DD>the parsed value, or <code>null</code> if the parse fails</DL></DD></DL><HR><A NAME="getDecimalFormatSymbols()"><!-- --></A><H3>getDecimalFormatSymbols</H3><PRE>public <A HREF="../../java/text/DecimalFormatSymbols.html">DecimalFormatSymbols</A> <B>getDecimalFormatSymbols</B>()</PRE><DL><DD>Returns the decimal format symbols, which is generally not changed by the programmer or user.<DD><DL><DT><B>Returns:</B><DD>desired DecimalFormatSymbols<DT><B>See Also: </B><DD><A HREF="../../java/text/DecimalFormatSymbols.html"><CODE>DecimalFormatSymbols</CODE></A></DL></DD></DL><HR><A NAME="setDecimalFormatSymbols(java.text.DecimalFormatSymbols)"><!-- --></A><H3>setDecimalFormatSymbols</H3><PRE>public void <B>setDecimalFormatSymbols</B>(<A HREF="../../java/text/DecimalFormatSymbols.html">DecimalFormatSymbols</A> newSymbols)</PRE><DL><DD>Sets the decimal format symbols, which is generally not changed by the programmer or user.<DD><DL><DT><B>Parameters:</B><DD><CODE>newSymbols</CODE> - desired DecimalFormatSymbols<DT><B>See Also: </B><DD><A HREF="../../java/text/DecimalFormatSymbols.html"><CODE>DecimalFormatSymbols</CODE></A></DL></DD></DL><HR><A NAME="getPositivePrefix()"><!-- --></A><H3>getPositivePrefix</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getPositivePrefix</B>()</PRE><DL><DD>Get the positive prefix. <P>Examples: +123, $123, sFr123</DL><HR><A NAME="setPositivePrefix(java.lang.String)"><!-- --></A><H3>setPositivePrefix</H3><PRE>public void <B>setPositivePrefix</B>(<A HREF="../../java/lang/String.html">String</A> newValue)</PRE><DL><DD>Set the positive prefix. <P>Examples: +123, $123, sFr123</DL><HR><A NAME="getNegativePrefix()"><!-- --></A><H3>getNegativePrefix</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getNegativePrefix</B>()</PRE><DL><DD>Get the negative prefix. <P>Examples: -123, ($123) (with negative suffix), sFr-123</DL><HR><A NAME="setNegativePrefix(java.lang.String)"><!-- --></A><H3>setNegativePrefix</H3><PRE>public void <B>setNegativePrefix</B>(<A HREF="../../java/lang/String.html">String</A> newValue)</PRE><DL><DD>Set the negative prefix. <P>Examples: -123, ($123) (with negative suffix), sFr-123</DL><HR><A NAME="getPositiveSuffix()"><!-- --></A><H3>getPositiveSuffix</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getPositiveSuffix</B>()</PRE><DL><DD>Get the positive suffix. <P>Example: 123%</DL><HR><A NAME="setPositiveSuffix(java.lang.String)"><!-- --></A><H3>setPositiveSuffix</H3><PRE>public void <B>setPositiveSuffix</B>(<A HREF="../../java/lang/String.html">String</A> newValue)</PRE><DL><DD>Set the positive suffix. <P>Example: 123%</DL><HR><A NAME="getNegativeSuffix()"><!-- --></A><H3>getNegativeSuffix</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>getNegativeSuffix</B>()</PRE><DL><DD>Get the negative suffix. <P>Examples: -123%, ($123) (with positive suffixes)</DL><HR><A NAME="setNegativeSuffix(java.lang.String)"><!-- --></A><H3>setNegativeSuffix</H3><PRE>public void <B>setNegativeSuffix</B>(<A HREF="../../java/lang/String.html">String</A> newValue)</PRE><DL><DD>Set the positive suffix. <P>Examples: 123%</DL><HR><A NAME="getMultiplier()"><!-- --></A><H3>getMultiplier</H3><PRE>public int <B>getMultiplier</B>()</PRE><DL><DD>Get the multiplier for use in percent, permill, etc. For a percentage, set the suffixes to have "%" and the multiplier to be 100. (For Arabic, use arabic percent symbol). For a permill, set the suffixes to have "?" and the multiplier to be 1000. <P>Examples: with 100, 1.23 -> "123", and "123" -> 1.23</DL><HR><A NAME="setMultiplier(int)"><!-- --></A><H3>setMultiplier</H3><PRE>public void <B>setMultiplier</B>(int newValue)</PRE><DL><DD>Set the multiplier for use in percent, permill, etc. For a percentage, set the suffixes to have "%" and the multiplier to be 100. (For Arabic, use arabic percent symbol). For a permill, set the suffixes to have "?" and the multiplier to be 1000. <P>Examples: with 100, 1.23 -> "123", and "123" -> 1.23</DL><HR><A NAME="getGroupingSize()"><!-- --></A><H3>getGroupingSize</H3><PRE>public int <B>getGroupingSize</B>()</PRE><DL><DD>Return the grouping size. Grouping size is the number of digits between grouping separators in the integer portion of a number. For example, in the number "123,456.78", the grouping size is 3.<DD><DL><DT><B>See Also: </B><DD><A HREF="../../java/text/DecimalFormat.html#setGroupingSize(int)"><CODE>setGroupingSize(int)</CODE></A>, <A HREF="../../java/text/NumberFormat.html#isGroupingUsed()"><CODE>NumberFormat.isGroupingUsed()</CODE></A>, <A HREF="../../java/text/DecimalFormatSymbols.html#getGroupingSeparator()"><CODE>DecimalFormatSymbols.getGroupingSeparator()</CODE></A></DL></DD></DL><HR><A NAME="setGroupingSize(int)"><!-- --></A><H3>setGroupingSize</H3><PRE>public void <B>setGroupingSize</B>(int newValue)</PRE><DL><DD>Set the grouping size. Grouping size is the number of digits between grouping separators in the integer portion of a number. For example, in the number "123,456.78", the grouping size is 3.<DD><DL><DT><B>See Also: </B><DD><A HREF="../../java/text/DecimalFormat.html#getGroupingSize()"><CODE>getGroupingSize()</CODE></A>, <A HREF="../../java/text/NumberFormat.html#setGroupingUsed(boolean)"><CODE>NumberFormat.setGroupingUsed(boolean)</CODE></A>, <A HREF="../../java/text/DecimalFormatSymbols.html#setGroupingSeparator(char)"><CODE>DecimalFormatSymbols.setGroupingSeparator(char)</CODE></A></DL></DD></DL><HR><A NAME="isDecimalSeparatorAlwaysShown()"><!-- --></A><H3>isDecimalSeparatorAlwaysShown</H3><PRE>public boolean <B>isDecimalSeparatorAlwaysShown</B>()</PRE><DL>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?