KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > java > text > NumberFormat

java.text
Class NumberFormat

java.lang.Object
  extended by java.text.Format
      extended by java.text.NumberFormat
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
ChoiceFormat, DecimalFormat
See Also:
Top Examples, Source Code

public Object clone()
See Also:
Cloneable, Format
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean equals(Object obj)
See Also:
Hashtable, Object.hashCode()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String format(double number)
See Also:
Format.format(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[23]Format big decimal
By Max Okist on 2005/05/17 10:46:29  Rate
public String format (  )   {  
    double d = 4.935126; 
    NumberFormat formatter = new DecimalFormat ( "0.0" ) ; 
    String s = formatter.format ( d ) ; 
    return s; 
  }  
 


[581]Format currency in specific locale
By John Zoetebier on 2005/09/06 17:16:57  Rate
    Locale locale = Locale.getDefault (  ) ; 
     NumberFormat format = NumberFormat.getCurrencyInstance ( locale ) ;  
     double positive = 123.456; 
     double negative = -123.456; 
     System.out.println ( "positive=" + format.format ( positive )  ) ; 
     System.out.println ( "negative=" + format.format ( negative )  ) ; 
     


public abstract StringBuffer format(double number,
                                    StringBuffer toAppendTo,
                                    FieldPosition pos)
See Also:
Format.format(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuffer format(Object number,
                           StringBuffer toAppendTo,
                           FieldPosition pos)
See Also:
NullPointerException, IllegalArgumentException, Format, format(double,java.lang.StringBuffer,java.text.FieldPosition), format(long,java.lang.StringBuffer,java.text.FieldPosition), Number.doubleValue(), bit length, Number.longValue()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final String format(long number)
See Also:
Format.format(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract StringBuffer format(long number,
                                    StringBuffer toAppendTo,
                                    FieldPosition pos)
See Also:
Format.format(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int FRACTION_FIELD
See Also:
FieldPosition
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static Locale[] getAvailableLocales()
See Also:
Locale.US
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Currency getCurrency()
See Also:
UnsupportedOperationException, setCurrency
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1475]Print currency in a locale-specific format
By Sandy on 2005/07/08 08:47:39  Rate
The getCurrency (  )  method returns a java.util.Currency object.  
  
  
 You can print it directly using System.out.println (  ) , as the toString (  )  method in java.util.Currency is overridden to return the Currency Code  ( USD,.... ) . 
  
  
 If your current Locale is US, the following code will print " USD ". 
  
  
 import java.text.NumberFormat; 
 import java.util.Currency; 
  
  
 public class CurrencyClass 
  {  
   public static void main ( String args [  ]  )  
    {  
    NumberFormat formatter = NumberFormat.getInstance (  ) ; 
    System.out.println ( formatter.getCurrency (  )  ) ; 
    }    
  } 


public static final NumberFormat getCurrencyInstance()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[461]Representation of a number in a currency format
By Anonymous on 2004/03/27 19:03:07  Rate
NumberFormat csh = NumberFormat.getCurrencyInstance (  ) ;

public static NumberFormat getCurrencyInstance(Locale inLocale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final NumberFormat getInstance()
See Also:
getNumberInstance()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static NumberFormat getInstance(Locale inLocale)
See Also:
getNumberInstance(inLocale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final NumberFormat getIntegerInstance()
See Also:
isParseIntegerOnly, ROUND_HALF_EVEN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static NumberFormat getIntegerInstance(Locale inLocale)
See Also:
isParseIntegerOnly, ROUND_HALF_EVEN
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getMaximumFractionDigits()
See Also:
setMaximumFractionDigits(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getMaximumIntegerDigits()
See Also:
setMaximumIntegerDigits(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getMinimumFractionDigits()
See Also:
setMinimumFractionDigits(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getMinimumIntegerDigits()
See Also:
setMinimumIntegerDigits(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final NumberFormat getNumberInstance()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static NumberFormat getNumberInstance(Locale inLocale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final NumberFormat getPercentInstance()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[935]Format a number in percentage
By juan_francisco_monroy_estrada { at } hotmail { dot } com on 2004/11/15 09:22:46  Rate
double d = 4.935126;  
 String s1= NumberFormat.getPercentInstance (  ) .format ( d ) ;  
 System.out.println ( s1 ) ; 
  
  
 ============================== 
  
  
 494%


public static NumberFormat getPercentInstance(Locale inLocale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int hashCode()
See Also:
Hashtable, Object.equals(java.lang.Object)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final int INTEGER_FIELD
See Also:
FieldPosition
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isGroupingUsed()
See Also:
setGroupingUsed(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isParseIntegerOnly()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public NumberFormat()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Number parse(String source)
             throws ParseException
See Also:
parse(String, ParsePosition)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public abstract Number parse(String source,
                             ParsePosition parsePosition)
See Also:
Format.parseObject(java.lang.String, java.text.ParsePosition), isParseIntegerOnly()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public final Object parseObject(String source,
                                ParsePosition pos)
See Also:
NullPointerException, Format, parse(String, ParsePosition)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setCurrency(Currency currency)
See Also:
NullPointerException, UnsupportedOperationException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setGroupingUsed(boolean newValue)
See Also:
isGroupingUsed()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setMaximumFractionDigits(int newValue)
See Also:
getMaximumFractionDigits()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setMaximumIntegerDigits(int newValue)
See Also:
getMaximumIntegerDigits()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setMinimumFractionDigits(int newValue)
See Also:
getMinimumFractionDigits()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setMinimumIntegerDigits(int newValue)
See Also:
getMinimumIntegerDigits()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setParseIntegerOnly(boolean value)
See Also:
isParseIntegerOnly()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags