java.lang.Object
java.text.Format
java.text.NumberFormat
java.text.DecimalFormat
- All Implemented Interfaces:
- Serializable, Cloneable
- See Also:
- Top Examples, Source Code,
Character.digit
, ROUND_HALF_EVEN
,
DecimalFormatSymbols
,
ParsePosition
public void applyLocalizedPattern(String pattern)
- See Also:
- IllegalArgumentException, NullPointerException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void applyPattern(String pattern)
- See Also:
- IllegalArgumentException, NullPointerException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Object clone()
- See Also:
Cloneable
, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public DecimalFormat()
- See Also:
NumberFormat.getPercentInstance()
, NumberFormat.getCurrencyInstance()
, NumberFormat.getNumberInstance()
, NumberFormat.getInstance()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1422]Format decimal number
By tsatsulin_v_n { at } yahoo { dot } com on 2005/05/12 02:15:23 Rate
import java.text.*;
public class DecFtDemo {
public static void main ( String f [ ] ) {
DecimalFormat df = new DecimalFormat ( ) ;
System.out.println ( df.format ( -4.3279 ) ) ;
System.out.println ( df.format ( 2174534.3279 ) ) ;
}
}
Result:
-4.328
2,174,534.328
public DecimalFormat(String pattern)
- See Also:
NumberFormat.getPercentInstance()
, NumberFormat.getCurrencyInstance()
, NumberFormat.getNumberInstance()
, NumberFormat.getInstance()
, IllegalArgumentException, NullPointerException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[34]Different formats of decimal number
By Anonymous on 2005/03/08 14:24:43 Rate
DecimalFormat format = new DecimalFormat ( "#,##0.0000" ) ;
FieldPosition f = new FieldPosition ( 0 ) ;
StringBuffer s = new StringBuffer ( ) ;
format.format ( myDouble, s, f ) ;
[546]_
By Checker on 2004/12/16 21:36:56 Rate
// Use the symbol ' to quote literal symbols
NumberFormat f = new DecimalFormat ( "'#'#" ) ;
s = f.format ( -1234.5678 ) ; // -#1235
f = new DecimalFormat ( "'AEF'#" ) ;
s = f.format ( -1234.567 ) ; // -AEF1235
[714]_
By Anonymous on 2005/02/23 00:57:01 Rate
DecimalFormat df = new DecimalFormat ( ) ;
df.setMaximumFractionDigits ( 2 ) ;
df.setMinimumFractionDigits ( 2 ) ;
df.setDecimalSeparatorAlwaysShown ( true ) ;
[1332]Do not call the DecimalFormat constructor directly
By Bruce Ingalls http://emacro { dot } sourceforge { dot } net/ on 2005/03/08 14:35:19 Rate
The Java API docs for some time, have recommended against calling the DecimalFormat constructor directly. Java Docs starting with Tiger aka 1.5 aka 5.0 include a partial example.
public DecimalFormat(String pattern,
DecimalFormatSymbols symbols)
- See Also:
-
NumberFormat.getPercentInstance()
, NumberFormat.getCurrencyInstance()
, NumberFormat.getNumberInstance()
, NumberFormat.getInstance()
, IllegalArgumentException, NullPointerException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1889]Convert number to string with preceding zeros
By Anonymous on 2007/06/11 22:34:03 Rate
//Convert to 7 digit strings
DecimalFormat myFormatter = new DecimalFormat ( "0000000" ) ;
String output = myFormatter.format ( 1 ) ;
public boolean equals(Object obj)
- See Also:
Hashtable
, Object.hashCode()
, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public StringBuffer format(double number,
StringBuffer result,
FieldPosition fieldPosition)
- See Also:
- NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public final StringBuffer format(Object number,
StringBuffer toAppendTo,
FieldPosition pos)
- See Also:
- NullPointerException, IllegalArgumentException, NumberFormat,
Number
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public StringBuffer format(long number,
StringBuffer result,
FieldPosition fieldPosition)
- See Also:
- NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public AttributedCharacterIterator formatToCharacterIterator(Object obj)
- See Also:
- IllegalArgumentException, NullPointerException, Format
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Currency getCurrency()
- See Also:
- NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public DecimalFormatSymbols getDecimalFormatSymbols()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getGroupingSize()
- See Also:
DecimalFormatSymbols.getGroupingSeparator()
, NumberFormat.isGroupingUsed()
, setGroupingSize(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMaximumFractionDigits()
- See Also:
setMaximumFractionDigits(int)
, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMaximumIntegerDigits()
- See Also:
setMaximumIntegerDigits(int)
, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMinimumFractionDigits()
- See Also:
setMinimumFractionDigits(int)
, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMinimumIntegerDigits()
- See Also:
setMinimumIntegerDigits(int)
, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int getMultiplier()
- See Also:
setMultiplier(int)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getNegativePrefix()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getNegativeSuffix()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getPositivePrefix()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getPositiveSuffix()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int hashCode()
- See Also:
Hashtable
, Object.equals(java.lang.Object)
, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isDecimalSeparatorAlwaysShown()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public boolean isParseBigDecimal()
- See Also:
setParseBigDecimal(boolean)
, parse(java.lang.String, java.text.ParsePosition)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Number parse(String text,
ParsePosition pos)
- See Also:
Format.parseObject(java.lang.String, java.text.ParsePosition)
, NumberFormat.isParseIntegerOnly()
, NullPointerException, BigDecimal.BigDecimal(String)
, isParseBigDecimal()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setCurrency(Currency currency)
- See Also:
- NullPointerException, NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setDecimalFormatSymbols(DecimalFormatSymbols newSymbols)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setDecimalSeparatorAlwaysShown(boolean newValue)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setGroupingSize(int newValue)
- See Also:
DecimalFormatSymbols.setGroupingSeparator(char)
, NumberFormat.setGroupingUsed(boolean)
, getGroupingSize()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setMaximumFractionDigits(int newValue)
- See Also:
- NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[789]Format a double in a nice percent format
By Jeff Hoeft on 2004/05/20 20:10:39 Rate
public String getPercentageValue ( double d ) {
NumberFormat nf = NumberFormat.getPercentInstance ( Locale.US ) ;
nf.setMaximumFractionDigits ( 4 ) ;
return nf.format ( d ) ;
}
public void setMaximumIntegerDigits(int newValue)
- See Also:
- NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setMinimumFractionDigits(int newValue)
- See Also:
- NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setMinimumIntegerDigits(int newValue)
- See Also:
- NumberFormat
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setMultiplier(int newValue)
- See Also:
getMultiplier()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setNegativePrefix(String newValue)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setNegativeSuffix(String newValue)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setParseBigDecimal(boolean newValue)
- See Also:
isParseBigDecimal()
, parse(java.lang.String, java.text.ParsePosition)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setPositivePrefix(String newValue)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setPositiveSuffix(String newValue)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String toLocalizedPattern()
- See Also:
applyPattern(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String toPattern()
- See Also:
applyPattern(java.lang.String)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples