Package oracle.i18n.text
Class OraDecimalFormat
- java.lang.Object
-
- java.text.Format
-
- oracle.i18n.text.OraNumberFormat
-
- oracle.i18n.text.OraDecimalFormat
-
- All Implemented Interfaces:
Serializable
,Cloneable
public class OraDecimalFormat extends OraNumberFormat
TheOraDecimalFormat
class is a concrete class to do locale-sensitive formatting and parsing between number and string. It supports Oracle number formatting behavior.- See Also:
OraNumberFormat
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.text.Format
Format.Field
-
-
Field Summary
-
Fields inherited from class oracle.i18n.text.OraNumberFormat
ALL_FIELD, FRACTION_FIELD, INTEGER_FIELD, SQLImplicit
-
-
Constructor Summary
Constructors Constructor Description OraDecimalFormat()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced byOraDecimalFormat(String, OraDecimalFormatSymbols)
OraDecimalFormat(String pattern)
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced byOraDecimalFormat(String, OraDecimalFormatSymbols)
OraDecimalFormat(String pattern, OraDecimalFormatSymbols symbols)
Constructs anOraDecimalFormat
object using the given format pattern and the given decimal format symbols.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyPattern(String pattern)
Modifies this formatter by using the given format pattern.Object
clone()
Overrides theclone
method.boolean
equals(Object object)
Overrides theequals
method.StringBuffer
format(double number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats a double number into a string.StringBuffer
format(long number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats a long number into a string.StringBuffer
format(BigDecimal number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats aBigDecimal
object into a string.StringBuffer
format(BigInteger number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats aBigInteger
object into a string.OraDecimalFormatSymbols
getOraDecimalFormatSymbols()
Returns the Oracle decimal format symbols used in this formatter.int
hashCode()
Overrides thehashCode
method.boolean
isDecimalSeparatorAlwaysShown()
Returnstrue
if decimal separator is always shown in the result string.Number
parse(String text, ParsePosition parsePosition)
Parses a string into aNumber
object, starting from the given parse position.void
setDecimalSeparatorAlwaysShown(boolean val)
Sets the switch for decimal separator to the given boolean value.protected void
setMaximumFractionDigits(int val)
protected void
setMaximumIntegerDigits(int val)
protected void
setMinimumFractionDigits(int val)
protected void
setMinimumIntegerDigits(int val)
void
setOraDecimalFormatSymbols(OraDecimalFormatSymbols sym)
Sets this formatter to use the given Oracle decimal format symbols.String
toPattern()
Returns a format pattern string that represents the formatting behavior of this formatter.-
Methods inherited from class oracle.i18n.text.OraNumberFormat
format, format, format, format, format, getCurrencyInstance, getCurrencyInstance, getCurrencyInstance, getDefaultCurrencyFormatPattern, getDefaultCurrencyFormatPattern, getDefaultNumberFormatPattern, getDefaultNumberFormatPattern, getInstance, getInstance, getInstance, getMaximumFractionDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getNumberInstance, getSQLImplicitInstance, getSQLImplicitInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setGroupingUsed, setParseIntegerOnly
-
Methods inherited from class java.text.Format
format, formatToCharacterIterator, parseObject
-
-
-
-
Constructor Detail
-
OraDecimalFormat
public OraDecimalFormat()
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced byOraDecimalFormat(String, OraDecimalFormatSymbols)
Constructs anOraDecimalFormat
object using the default number format pattern and the default decimal format symbols for the default locale.
-
OraDecimalFormat
public OraDecimalFormat(String pattern) throws ParseException
Deprecated.As of Oracle Database 10g Release 2 (10.2), replaced byOraDecimalFormat(String, OraDecimalFormatSymbols)
Constructs anOraDecimalFormat
object using the given format pattern and the default decimal format symbols for the default locale.- Parameters:
pattern
- the given format pattern, if null, uses the default number format pattern for the default locale and supports SQL TO_CHAR()/TO_NUMBER() implicit conversion.- Throws:
ParseException
- if the given pattern is invalid
-
OraDecimalFormat
public OraDecimalFormat(String pattern, OraDecimalFormatSymbols symbols) throws ParseException
Constructs anOraDecimalFormat
object using the given format pattern and the given decimal format symbols.- Parameters:
pattern
- the give format pattern, if null, uses the default number format pattern for the default locale and supports SQL TO_CHAR()/TO_NUMBER() implicit conversion.symbols
- the given decimal format symbols- Throws:
ParseException
- if the given pattern is invalid
-
-
Method Detail
-
applyPattern
public void applyPattern(String pattern) throws ParseException
Modifies this formatter by using the given format pattern. The given format pattern should be specified as:"<positive pattern>[;<negative pattern>]"
This means that a positive format pattern must be present but a negative format pattern is optional. If there is no negative pattern given, the positive pattern with a leading minus sign is used for formatting or parsing negative numbers.- Parameters:
pattern
- given format pattern, if null, uses the default number format pattern for the default locale and supports SQL TO_CHAR()/TO_NUMBER() implicit conversion.- Throws:
ParseException
- if the given pattern is invalid
-
format
public StringBuffer format(BigDecimal number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats aBigDecimal
object into a string. Sets field position if it is needed.- Specified by:
format
in classOraNumberFormat
- Parameters:
number
- theBigDecimal
object to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.fieldPosition
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
format
public StringBuffer format(BigInteger number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats aBigInteger
object into a string. Sets field position if it is needed.- Specified by:
format
in classOraNumberFormat
- Parameters:
number
- theBigInteger
object to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.fieldPosition
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
format
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats a double number into a string. Sets field position if it is needed.- Specified by:
format
in classOraNumberFormat
- Parameters:
number
- the double number to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.fieldPosition
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
format
public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition fieldPosition)
Formats a long number into a string. Sets field position if it is needed.- Specified by:
format
in classOraNumberFormat
- Parameters:
number
- the long number to be formatted.toAppendTo
- the string buffer to be appended with the formatted string.fieldPosition
- to be used to get offsets of a given field in the returned string buffer. On input, the alignment field of which the offsets are to be returned. On output, the offsets of the alignment field in the returned string buffer.- Returns:
- the string buffer appended with a formatted string
-
parse
public Number parse(String text, ParsePosition parsePosition)
Parses a string into aNumber
object, starting from the given parse position.- Specified by:
parse
in classOraNumberFormat
- Parameters:
text
- the stringparsePosition
- indicates where to start the parsing on input. On output, returns where the parse ends if parsing succeeds, or the start index if it fails.- Returns:
- a
Number
object
-
isDecimalSeparatorAlwaysShown
public boolean isDecimalSeparatorAlwaysShown()
Returnstrue
if decimal separator is always shown in the result string.- Returns:
- a boolean value
-
setDecimalSeparatorAlwaysShown
public void setDecimalSeparatorAlwaysShown(boolean val)
Sets the switch for decimal separator to the given boolean value.- Parameters:
val
- the given boolean value
-
getOraDecimalFormatSymbols
public OraDecimalFormatSymbols getOraDecimalFormatSymbols()
Returns the Oracle decimal format symbols used in this formatter.- Returns:
- an
OraDecimalFormatSymbols
object - See Also:
OraDecimalFormatSymbols
-
setOraDecimalFormatSymbols
public void setOraDecimalFormatSymbols(OraDecimalFormatSymbols sym)
Sets this formatter to use the given Oracle decimal format symbols.- Parameters:
sym
- the given Oracle decimal format symbols
-
toPattern
public String toPattern()
Returns a format pattern string that represents the formatting behavior of this formatter.- Returns:
- a format pattern string
-
setMaximumIntegerDigits
protected void setMaximumIntegerDigits(int val)
- Overrides:
setMaximumIntegerDigits
in classOraNumberFormat
-
setMinimumIntegerDigits
protected void setMinimumIntegerDigits(int val)
- Overrides:
setMinimumIntegerDigits
in classOraNumberFormat
-
setMaximumFractionDigits
protected void setMaximumFractionDigits(int val)
- Overrides:
setMaximumFractionDigits
in classOraNumberFormat
-
setMinimumFractionDigits
protected void setMinimumFractionDigits(int val)
- Overrides:
setMinimumFractionDigits
in classOraNumberFormat
-
clone
public Object clone()
Overrides theclone
method.- Overrides:
clone
in classOraNumberFormat
- Returns:
- a cloned object
-
equals
public boolean equals(Object object)
Overrides theequals
method.- Overrides:
equals
in classOraNumberFormat
- Parameters:
object
- an object to be compared- Returns:
true
if two objects are identical, otherwisefalse
-
-