Java Doc for DecimalFormat.java in  » Apache-Harmony-Java-SE » java-package » java » text » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.text 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.text.Format
      java.text.NumberFormat
         java.text.DecimalFormat

DecimalFormat
public class DecimalFormat extends NumberFormat (Code)
DecimalFormat is used to format and parse numbers, both integers and fractions, based on a pattern. The pattern characters used can be either localized or non-localized.



Constructor Summary
public  DecimalFormat()
     Constructs a new DecimalFormat for formatting and parsing numbers for the default Locale.
public  DecimalFormat(String pattern)
     Constructs a new DecimalFormat using the specified non-localized pattern and the DecimalFormatSymbols for the default Locale.
public  DecimalFormat(String pattern, DecimalFormatSymbols value)
     Constructs a new DecimalFormat using the specified non-localized pattern and DecimalFormatSymbols.

Method Summary
public  voidapplyLocalizedPattern(String pattern)
     Changes the pattern of this DecimalFormat to the specified pattern which uses localized pattern characters.
public  voidapplyPattern(String pattern)
     Changes the pattern of this SimpleDateFormat to the specified pattern which uses non-localized pattern characters.
public  Objectclone()
     Answers a new instance of DecimalFormat with the same pattern and properties as this DecimalFormat.
public  booleanequals(Object object)
     Compares the specified object to this DecimalFormat and answer if they are equal.
public  StringBufferformat(double value, StringBuffer buffer, FieldPosition position)
     Formats the double value into the specified StringBuffer using the pattern of this DecimalFormat.
public  StringBufferformat(long value, StringBuffer buffer, FieldPosition position)
     Formats the long value into the specified StringBuffer using the pattern of this DecimalFormat.
final public  StringBufferformat(Object number, StringBuffer toAppendTo, FieldPosition pos)
     Formats the number into the specified StringBuffer using the pattern of this DecimalFormat.
public  AttributedCharacterIteratorformatToCharacterIterator(Object object)
     Formats the specified object using the rules of this DecimalNumberFormat and returns an AttributedCharacterIterator with the formatted number and attributes.
public  CurrencygetCurrency()
     Answers the currency used by this decimal format.
public  DecimalFormatSymbolsgetDecimalFormatSymbols()
     Answers the DecimalFormatSymbols used by this DecimalFormat.
public  intgetGroupingSize()
     Answers the number of digits grouped together by the grouping separator.
public  intgetMultiplier()
     Answers the multiplier which is applied to the number before formatting or after parsing.
public  StringgetNegativePrefix()
     Answers the prefix which is formatted or parsed before a negative number.
public  StringgetNegativeSuffix()
     Answers the suffix which is formatted or parsed after a negative number.
public  StringgetPositivePrefix()
     Answers the prefix which is formatted or parsed before a positive number.
public  StringgetPositiveSuffix()
     Answers the suffix which is formatted or parsed after a positive number.
public  inthashCode()
     Answers an integer hash code for the receiver.
public  booleanisDecimalSeparatorAlwaysShown()
     Answers whether the decimal separator is shown when there are no fractional digits.
public  booleanisGroupingUsed()
     This value indicates whether grouping will be used in this format.
public  booleanisParseBigDecimal()
     This value indicates whether the return object of the parse operation will be of type BigDecimal.
public  booleanisParseIntegerOnly()
    
public  Numberparse(String string, ParsePosition position)
     Parse a Long or Double from the specified String starting at the index specified by the ParsePosition.
public  voidsetCurrency(Currency currency)
     Sets the currency used by this decimal format.
public  voidsetDecimalFormatSymbols(DecimalFormatSymbols value)
     Sets the DecimalFormatSymbols used by this DecimalFormat.
public  voidsetDecimalSeparatorAlwaysShown(boolean value)
     Sets whether the decimal separator is shown when there are no fractional digits.
public  voidsetGroupingSize(int value)
     Sets the number of digits grouped together by the grouping separator.
public  voidsetGroupingUsed(boolean value)
     Sets whether or not grouping will be used in this format.
public  voidsetMaximumFractionDigits(int value)
     Sets the maximum number of fraction digits that are printed when formatting.
public  voidsetMaximumIntegerDigits(int value)
     Sets the maximum number of integer digits that are printed when formatting.
public  voidsetMinimumFractionDigits(int value)
     Sets the minimum number of fraction digits that are printed when formatting.
public  voidsetMinimumIntegerDigits(int value)
     Sets the minimum number of integer digits that are printed when formatting.
public  voidsetMultiplier(int value)
     Sets the multiplier which is applied to the number before formatting or after parsing.
public  voidsetNegativePrefix(String value)
     Sets the prefix which is formatted or parsed before a negative number.
public  voidsetNegativeSuffix(String value)
     Sets the suffix which is formatted or parsed after a negative number.
public  voidsetParseBigDecimal(boolean newValue)
    
public  voidsetParseIntegerOnly(boolean value)
     When DecimalFormat is used to parsing, and this value is set to true, then all the resulting number will be of type java.lang.Integer.
public  voidsetPositivePrefix(String value)
     Sets the prefix which is formatted or parsed before a positive number.
public  voidsetPositiveSuffix(String value)
     Sets the suffix which is formatted or parsed after a positive number.
public  StringtoLocalizedPattern()
     Answers the pattern of this DecimalFormat using localized pattern characters.
public  StringtoPattern()
     Answers the pattern of this DecimalFormat using non-localized pattern characters.


Constructor Detail
DecimalFormat
public DecimalFormat()(Code)
Constructs a new DecimalFormat for formatting and parsing numbers for the default Locale.



DecimalFormat
public DecimalFormat(String pattern)(Code)
Constructs a new DecimalFormat using the specified non-localized pattern and the DecimalFormatSymbols for the default Locale.
Parameters:
  pattern - the non-localized pattern
exception:
  IllegalArgumentException - when the pattern cannot be parsed



DecimalFormat
public DecimalFormat(String pattern, DecimalFormatSymbols value)(Code)
Constructs a new DecimalFormat using the specified non-localized pattern and DecimalFormatSymbols.
Parameters:
  pattern - the non-localized pattern
Parameters:
  value - the DecimalFormatSymbols
exception:
  IllegalArgumentException - when the pattern cannot be parsed




Method Detail
applyLocalizedPattern
public void applyLocalizedPattern(String pattern)(Code)
Changes the pattern of this DecimalFormat to the specified pattern which uses localized pattern characters.
Parameters:
  pattern - the localized pattern
exception:
  IllegalArgumentException - when the pattern cannot be parsed



applyPattern
public void applyPattern(String pattern)(Code)
Changes the pattern of this SimpleDateFormat to the specified pattern which uses non-localized pattern characters.
Parameters:
  pattern - the non-localized pattern
exception:
  IllegalArgumentException - when the pattern cannot be parsed



clone
public Object clone()(Code)
Answers a new instance of DecimalFormat with the same pattern and properties as this DecimalFormat. a shallow copy of this DecimalFormat
See Also:   java.lang.Cloneable



equals
public boolean equals(Object object)(Code)
Compares the specified object to this DecimalFormat and answer if they are equal. The object must be an instance of DecimalFormat with the same pattern and properties.
Parameters:
  object - the object to compare with this object true if the specified object is equal to this DecimalFormat,false otherwise
See Also:   DecimalFormat.hashCode



format
public StringBuffer format(double value, StringBuffer buffer, FieldPosition position)(Code)
Formats the double value into the specified StringBuffer using the pattern of this DecimalFormat. If the field specified by the FieldPosition is formatted, set the begin and end index of the formatted field in the FieldPosition.
Parameters:
  value - the double to format
Parameters:
  buffer - the StringBuffer
Parameters:
  position - the FieldPosition the StringBuffer parameter buffer



format
public StringBuffer format(long value, StringBuffer buffer, FieldPosition position)(Code)
Formats the long value into the specified StringBuffer using the pattern of this DecimalFormat. If the field specified by the FieldPosition is formatted, set the begin and end index of the formatted field in the FieldPosition.
Parameters:
  value - the long to format
Parameters:
  buffer - the StringBuffer
Parameters:
  position - the FieldPosition the StringBuffer parameter buffer



format
final public StringBuffer format(Object number, StringBuffer toAppendTo, FieldPosition pos)(Code)
Formats the number into the specified StringBuffer using the pattern of this DecimalFormat. If the field specified by the FieldPosition is formatted, set the begin and end index of the formatted field in the FieldPosition.
Parameters:
  number - the object to format
Parameters:
  toAppendTo - the StringBuffer
Parameters:
  pos - the FieldPosition the StringBuffer parameter buffer
throws:
  IllegalArgumentException - if the given number is not instance of Number



formatToCharacterIterator
public AttributedCharacterIterator formatToCharacterIterator(Object object)(Code)
Formats the specified object using the rules of this DecimalNumberFormat and returns an AttributedCharacterIterator with the formatted number and attributes.
Parameters:
  object - the object to format an AttributedCharacterIterator with the formatted number andattributes
exception:
  NullPointerException - when the object is null
exception:
  IllegalArgumentException - when the object cannot be formatted by this Format



getCurrency
public Currency getCurrency()(Code)
Answers the currency used by this decimal format. currency of DecimalFormatSymbols used by this decimal format
See Also:   DecimalFormatSymbols.getCurrency



getDecimalFormatSymbols
public DecimalFormatSymbols getDecimalFormatSymbols()(Code)
Answers the DecimalFormatSymbols used by this DecimalFormat. a DecimalFormatSymbols



getGroupingSize
public int getGroupingSize()(Code)
Answers the number of digits grouped together by the grouping separator. the number of digits grouped together



getMultiplier
public int getMultiplier()(Code)
Answers the multiplier which is applied to the number before formatting or after parsing. the multiplier



getNegativePrefix
public String getNegativePrefix()(Code)
Answers the prefix which is formatted or parsed before a negative number. the negative prefix



getNegativeSuffix
public String getNegativeSuffix()(Code)
Answers the suffix which is formatted or parsed after a negative number. the negative suffix



getPositivePrefix
public String getPositivePrefix()(Code)
Answers the prefix which is formatted or parsed before a positive number. the positive prefix



getPositiveSuffix
public String getPositiveSuffix()(Code)
Answers the suffix which is formatted or parsed after a positive number. the positive suffix



hashCode
public int hashCode()(Code)
Answers an integer hash code for the receiver. Objects which are equal answer the same value for this method. the receiver's hash
See Also:   DecimalFormat.equals



isDecimalSeparatorAlwaysShown
public boolean isDecimalSeparatorAlwaysShown()(Code)
Answers whether the decimal separator is shown when there are no fractional digits. true if the decimal separator should always be formatted, falseotherwise



isGroupingUsed
public boolean isGroupingUsed()(Code)
This value indicates whether grouping will be used in this format. true if grouping is used,false otherwise.



isParseBigDecimal
public boolean isParseBigDecimal()(Code)
This value indicates whether the return object of the parse operation will be of type BigDecimal. This value will default to false. true and parse will always return BigDecimals, false and the typeof the result will be Long or Double.



isParseIntegerOnly
public boolean isParseIntegerOnly()(Code)
Returns true if this DecimalFormat's all resulting number will be of type java.lang.Integer true if this DecimalFormat's all resulting numberwill be of type java.lang.Integer



parse
public Number parse(String string, ParsePosition position)(Code)
Parse a Long or Double from the specified String starting at the index specified by the ParsePosition. If the string is successfully parsed, the index of the ParsePosition is updated to the index following the parsed text.
Parameters:
  string - the String to parse
Parameters:
  position - the ParsePosition, updated on return with the index followingthe parsed text, or on error the index is unchanged and theerror index is set to the index where the error occurred a Long or Double resulting from the parse, or null if there is anerror. The result will be a Long if the parsed number is aninteger in the range of a long, otherwise the result is a Double.



setCurrency
public void setCurrency(Currency currency)(Code)
Sets the currency used by this decimal format. The min and max fraction digits remain the same.
Parameters:
  currency -
See Also:   DecimalFormatSymbols.setCurrency(Currency)



setDecimalFormatSymbols
public void setDecimalFormatSymbols(DecimalFormatSymbols value)(Code)
Sets the DecimalFormatSymbols used by this DecimalFormat.
Parameters:
  value - the DecimalFormatSymbols



setDecimalSeparatorAlwaysShown
public void setDecimalSeparatorAlwaysShown(boolean value)(Code)
Sets whether the decimal separator is shown when there are no fractional digits.
Parameters:
  value - true if the decimal separator should always be formatted,false otherwise



setGroupingSize
public void setGroupingSize(int value)(Code)
Sets the number of digits grouped together by the grouping separator.
Parameters:
  value - the number of digits grouped together



setGroupingUsed
public void setGroupingUsed(boolean value)(Code)
Sets whether or not grouping will be used in this format. Grouping affects both parsing and formatting.
Parameters:
  value - true if uses grouping,false otherwise.



setMaximumFractionDigits
public void setMaximumFractionDigits(int value)(Code)
Sets the maximum number of fraction digits that are printed when formatting. If the maximum is less than the number of fraction digits, the least significant digits are truncated. Limit the maximum to DOUBLE_FRACTION_DIGITS.
Parameters:
  value - the maximum number of fraction digits



setMaximumIntegerDigits
public void setMaximumIntegerDigits(int value)(Code)
Sets the maximum number of integer digits that are printed when formatting. If the maximum is less than the number of integer digits, the most significant digits are truncated. Limit the maximum to DOUBLE_INTEGER_DIGITS.
Parameters:
  value - the maximum number of integer digits



setMinimumFractionDigits
public void setMinimumFractionDigits(int value)(Code)
Sets the minimum number of fraction digits that are printed when formatting. Limit the minimum to DOUBLE_FRACTION_DIGITS.
Parameters:
  value - the minimum number of fraction digits



setMinimumIntegerDigits
public void setMinimumIntegerDigits(int value)(Code)
Sets the minimum number of integer digits that are printed when formatting. Limit the minimum to DOUBLE_INTEGER_DIGITS.
Parameters:
  value - the minimum number of integer digits



setMultiplier
public void setMultiplier(int value)(Code)
Sets the multiplier which is applied to the number before formatting or after parsing.
Parameters:
  value - the multiplier



setNegativePrefix
public void setNegativePrefix(String value)(Code)
Sets the prefix which is formatted or parsed before a negative number.
Parameters:
  value - the negative prefix



setNegativeSuffix
public void setNegativeSuffix(String value)(Code)
Sets the suffix which is formatted or parsed after a negative number.
Parameters:
  value - the negative suffix



setParseBigDecimal
public void setParseBigDecimal(boolean newValue)(Code)
Let users change the behavior of a DecimalFormat, If set to true all the returned objects will be of type BigDecimal
Parameters:
  newValue - true if all the returned objects should be type of BigDecimal



setParseIntegerOnly
public void setParseIntegerOnly(boolean value)(Code)
When DecimalFormat is used to parsing, and this value is set to true, then all the resulting number will be of type java.lang.Integer. Except that, NaN, positive and negative infinity are still returned as java.lang.Double In this implementation, com.ibm.icu.text.DecimalFormat is wrapped to fulfill most of the format and parse feature. And this method is delegated to the wrapped instance of com.ibm.icu.text.DecimalFormat.
Parameters:
  value - If set to true, all the resulting number will be of typejava.lang.Integer except some special cases.



setPositivePrefix
public void setPositivePrefix(String value)(Code)
Sets the prefix which is formatted or parsed before a positive number.
Parameters:
  value - the positive prefix



setPositiveSuffix
public void setPositiveSuffix(String value)(Code)
Sets the suffix which is formatted or parsed after a positive number.
Parameters:
  value - the positive suffix



toLocalizedPattern
public String toLocalizedPattern()(Code)
Answers the pattern of this DecimalFormat using localized pattern characters. the localized pattern



toPattern
public String toPattern()(Code)
Answers the pattern of this DecimalFormat using non-localized pattern characters. the non-localized pattern



Fields inherited from java.text.NumberFormat
final public static int FRACTION_FIELD(Code)(Java Doc)
final public static int INTEGER_FIELD(Code)(Java Doc)

Methods inherited from java.text.NumberFormat
public Object clone()(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
final public String format(double value)(Code)(Java Doc)
abstract public StringBuffer format(double value, StringBuffer buffer, FieldPosition field)(Code)(Java Doc)
final public String format(long value)(Code)(Java Doc)
abstract public StringBuffer format(long value, StringBuffer buffer, FieldPosition field)(Code)(Java Doc)
public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field)(Code)(Java Doc)
public static Locale[] getAvailableLocales()(Code)(Java Doc)
public Currency getCurrency()(Code)(Java Doc)
final public static NumberFormat getCurrencyInstance()(Code)(Java Doc)
public static NumberFormat getCurrencyInstance(Locale locale)(Code)(Java Doc)
final public static NumberFormat getInstance()(Code)(Java Doc)
public static NumberFormat getInstance(Locale locale)(Code)(Java Doc)
final public static NumberFormat getIntegerInstance()(Code)(Java Doc)
public static NumberFormat getIntegerInstance(Locale locale)(Code)(Java Doc)
public int getMaximumFractionDigits()(Code)(Java Doc)
public int getMaximumIntegerDigits()(Code)(Java Doc)
public int getMinimumFractionDigits()(Code)(Java Doc)
public int getMinimumIntegerDigits()(Code)(Java Doc)
final public static NumberFormat getNumberInstance()(Code)(Java Doc)
public static NumberFormat getNumberInstance(Locale locale)(Code)(Java Doc)
final public static NumberFormat getPercentInstance()(Code)(Java Doc)
public static NumberFormat getPercentInstance(Locale locale)(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
public boolean isGroupingUsed()(Code)(Java Doc)
public boolean isParseIntegerOnly()(Code)(Java Doc)
public Number parse(String string) throws ParseException(Code)(Java Doc)
abstract public Number parse(String string, ParsePosition position)(Code)(Java Doc)
final public Object parseObject(String string, ParsePosition position)(Code)(Java Doc)
public void setCurrency(Currency currency)(Code)(Java Doc)
public void setGroupingUsed(boolean value)(Code)(Java Doc)
public void setMaximumFractionDigits(int value)(Code)(Java Doc)
public void setMaximumIntegerDigits(int value)(Code)(Java Doc)
public void setMinimumFractionDigits(int value)(Code)(Java Doc)
public void setMinimumIntegerDigits(int value)(Code)(Java Doc)
public void setParseIntegerOnly(boolean value)(Code)(Java Doc)

Methods inherited from java.text.Format
public Object clone()(Code)(Java Doc)
String convertPattern(String template, String fromChars, String toChars, boolean check)(Code)(Java Doc)
final public String format(Object object)(Code)(Java Doc)
abstract public StringBuffer format(Object object, StringBuffer buffer, FieldPosition field)(Code)(Java Doc)
public AttributedCharacterIterator formatToCharacterIterator(Object object)(Code)(Java Doc)
static Object getInternalField(String fieldName, Object target)(Code)(Java Doc)
public Object parseObject(String string) throws ParseException(Code)(Java Doc)
abstract public Object parseObject(String string, ParsePosition position)(Code)(Java Doc)
static boolean upTo(String string, ParsePosition position, StringBuffer buffer, char stop)(Code)(Java Doc)
static boolean upToWithQuotes(String string, ParsePosition position, StringBuffer buffer, char stop, char start)(Code)(Java Doc)

Methods inherited from java.lang.Object
protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object object)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final public Class<? extends Object> getClass()(Code)(Java Doc)
public int hashCode()(Code)(Java Doc)
final public void notify()(Code)(Java Doc)
final public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final public void wait(long millis, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait(long millis) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.