Package com.ibm.icu.impl
Class DateNumberFormat
- java.lang.Object
-
- java.text.Format
-
- com.ibm.icu.text.UFormat
-
- com.ibm.icu.text.NumberFormat
-
- com.ibm.icu.impl.DateNumberFormat
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public final class DateNumberFormat extends NumberFormat
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.icu.text.NumberFormat
NumberFormat.Field, NumberFormat.NumberFormatFactory, NumberFormat.SimpleNumberFormatFactory
-
Nested classes/interfaces inherited from class com.ibm.icu.text.UFormat
UFormat.SpanField
-
-
Field Summary
Fields Modifier and Type Field Description private static SimpleCache<ULocale,char[]>
CACHE
private static int
DECIMAL_BUF_SIZE
private char[]
decimalBuf
private char[]
digits
private int
maxIntDigits
private int
minIntDigits
private char
minusSign
private static long
PARSE_THRESHOLD
private boolean
positiveOnly
private static long
serialVersionUID
private char
zeroDigit
-
Fields inherited from class com.ibm.icu.text.NumberFormat
ACCOUNTINGCURRENCYSTYLE, CASHCURRENCYSTYLE, CURRENCYSTYLE, FRACTION_FIELD, INTEGER_FIELD, INTEGERSTYLE, ISOCURRENCYSTYLE, NUMBERSTYLE, PERCENTSTYLE, PLURALCURRENCYSTYLE, SCIENTIFICSTYLE, STANDARDCURRENCYSTYLE
-
-
Constructor Summary
Constructors Constructor Description DateNumberFormat(ULocale loc, char zeroDigit, java.lang.String nsName)
DateNumberFormat(ULocale loc, java.lang.String digitString, java.lang.String nsName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Overrides clone.boolean
equals(java.lang.Object obj)
Overrides equals.java.lang.StringBuffer
format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Specialization of format.java.lang.StringBuffer
format(long numberL, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Specialization of format.java.lang.StringBuffer
format(BigDecimal number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Formats an ICU BigDecimal.java.lang.StringBuffer
format(java.math.BigDecimal number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Formats a BigDecimal.java.lang.StringBuffer
format(java.math.BigInteger number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Formats a BigInteger.char[]
getDigits()
int
getMaximumIntegerDigits()
Returns the maximum number of digits allowed in the integer portion of a number.int
getMinimumIntegerDigits()
Returns the minimum number of digits allowed in the integer portion of a number.char
getZeroDigit()
int
hashCode()
private void
initialize(ULocale loc, java.lang.String digitString, java.lang.String nsName)
java.lang.Number
parse(java.lang.String text, java.text.ParsePosition parsePosition)
Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] and with no decimals); otherwise, returns another type, such as a BigDecimal, BigInteger, or Double.private void
readObject(java.io.ObjectInputStream stream)
void
setMaximumIntegerDigits(int newValue)
Sets the maximum number of digits allowed in the integer portion of a number.void
setMinimumIntegerDigits(int newValue)
Sets the minimum number of digits allowed in the integer portion of a number.void
setParsePositiveOnly(boolean isPositiveOnly)
void
setZeroDigit(char zero)
-
Methods inherited from class com.ibm.icu.text.NumberFormat
format, format, format, format, format, format, format, format, getAvailableLocales, getAvailableULocales, getContext, getCurrency, getCurrencyInstance, getCurrencyInstance, getCurrencyInstance, getEffectiveCurrency, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMinimumFractionDigits, getNumberInstance, getNumberInstance, getNumberInstance, getPattern, getPattern, getPatternForStyle, getPatternForStyleAndNumberingSystem, getPercentInstance, getPercentInstance, getPercentInstance, getRoundingMode, getScientificInstance, getScientificInstance, getScientificInstance, isGroupingUsed, isParseIntegerOnly, isParseStrict, parse, parseCurrency, parseObject, registerFactory, setContext, setCurrency, setGroupingUsed, setMaximumFractionDigits, setMinimumFractionDigits, setParseIntegerOnly, setParseStrict, setRoundingMode, unregister
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
digits
private char[] digits
-
zeroDigit
private char zeroDigit
-
minusSign
private char minusSign
-
positiveOnly
private boolean positiveOnly
-
DECIMAL_BUF_SIZE
private static final int DECIMAL_BUF_SIZE
- See Also:
- Constant Field Values
-
decimalBuf
private transient char[] decimalBuf
-
CACHE
private static SimpleCache<ULocale,char[]> CACHE
-
maxIntDigits
private int maxIntDigits
-
minIntDigits
private int minIntDigits
-
PARSE_THRESHOLD
private static final long PARSE_THRESHOLD
- See Also:
- Constant Field Values
-
-
Method Detail
-
initialize
private void initialize(ULocale loc, java.lang.String digitString, java.lang.String nsName)
-
setMaximumIntegerDigits
public void setMaximumIntegerDigits(int newValue)
Description copied from class:NumberFormat
Sets the maximum number of digits allowed in the integer portion of a number. This must be >= minimumIntegerDigits. If the new value for maximumIntegerDigits is less than the current value of minimumIntegerDigits, then minimumIntegerDigits will also be set to the new value.- Overrides:
setMaximumIntegerDigits
in classNumberFormat
- Parameters:
newValue
- the maximum number of integer digits to be shown; if less than zero, then zero is used. Subclasses might enforce an upper limit to this value appropriate to the numeric type being formatted.- See Also:
NumberFormat.getMaximumIntegerDigits()
-
getMaximumIntegerDigits
public int getMaximumIntegerDigits()
Description copied from class:NumberFormat
Returns the maximum number of digits allowed in the integer portion of a number. The default value is 40, which subclasses can override. When formatting, if the number of digits exceeds this value, the highest- significance digits are truncated until the limit is reached, in accordance with UTS#35. This setting has no effect on parsing.- Overrides:
getMaximumIntegerDigits
in classNumberFormat
- Returns:
- the maximum number of integer digits
- See Also:
NumberFormat.setMaximumIntegerDigits(int)
-
setMinimumIntegerDigits
public void setMinimumIntegerDigits(int newValue)
Description copied from class:NumberFormat
Sets the minimum number of digits allowed in the integer portion of a number. This must be <= maximumIntegerDigits. If the new value for minimumIntegerDigits is more than the current value of maximumIntegerDigits, then maximumIntegerDigits will also be set to the new value.- Overrides:
setMinimumIntegerDigits
in classNumberFormat
- Parameters:
newValue
- the minimum number of integer digits to be shown; if less than zero, then zero is used. Subclasses might enforce an upper limit to this value appropriate to the numeric type being formatted.- See Also:
NumberFormat.getMinimumIntegerDigits()
-
getMinimumIntegerDigits
public int getMinimumIntegerDigits()
Description copied from class:NumberFormat
Returns the minimum number of digits allowed in the integer portion of a number. The default value is 1, which subclasses can override. When formatting, if this value is not reached, numbers are padded on the left with the locale-specific '0' character to ensure at least this number of integer digits. When parsing, this has no effect.- Overrides:
getMinimumIntegerDigits
in classNumberFormat
- Returns:
- the minimum number of integer digits
- See Also:
NumberFormat.setMinimumIntegerDigits(int)
-
setParsePositiveOnly
public void setParsePositiveOnly(boolean isPositiveOnly)
-
getZeroDigit
public char getZeroDigit()
-
setZeroDigit
public void setZeroDigit(char zero)
-
getDigits
public char[] getDigits()
-
format
public java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Description copied from class:NumberFormat
Specialization of format.- Specified by:
format
in classNumberFormat
- See Also:
Format.format(Object, StringBuffer, FieldPosition)
-
format
public java.lang.StringBuffer format(long numberL, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Description copied from class:NumberFormat
Specialization of format.- Specified by:
format
in classNumberFormat
- See Also:
Format.format(Object, StringBuffer, FieldPosition)
-
format
public java.lang.StringBuffer format(java.math.BigInteger number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Description copied from class:NumberFormat
Formats a BigInteger. Specialization of format.- Specified by:
format
in classNumberFormat
- See Also:
Format.format(Object, StringBuffer, FieldPosition)
-
format
public java.lang.StringBuffer format(java.math.BigDecimal number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Description copied from class:NumberFormat
Formats a BigDecimal. Specialization of format.- Specified by:
format
in classNumberFormat
- See Also:
Format.format(Object, StringBuffer, FieldPosition)
-
format
public java.lang.StringBuffer format(BigDecimal number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
Description copied from class:NumberFormat
Formats an ICU BigDecimal. Specialization of format.- Specified by:
format
in classNumberFormat
- See Also:
Format.format(Object, StringBuffer, FieldPosition)
-
parse
public java.lang.Number parse(java.lang.String text, java.text.ParsePosition parsePosition)
Description copied from class:NumberFormat
Returns a Long if possible (e.g., within the range [Long.MIN_VALUE, Long.MAX_VALUE] and with no decimals); otherwise, returns another type, such as a BigDecimal, BigInteger, or Double. The return type is not guaranteed other than for the Long case.If IntegerOnly is set, will stop at a decimal point (or equivalent; e.g., for rational numbers "1 2/3", will stop after the 1).
Does not throw an exception; if no object can be parsed, index is unchanged!
For more detail on parsing, see the "Parsing" header in the class documentation of
DecimalFormat
.- Specified by:
parse
in classNumberFormat
- See Also:
NumberFormat.isParseIntegerOnly()
,DecimalFormat.setParseBigDecimal(boolean)
,Format.parseObject(String, ParsePosition)
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:NumberFormat
Overrides equals. Two NumberFormats are equal they are of the same class and the user-specified values for settings (groupingUsed, parseIntegerOnly, maximumIntegerDigits, etc.) are equal.- Overrides:
equals
in classNumberFormat
- Parameters:
obj
- the object to compare against- Returns:
- true if the object is equal to this.
-
hashCode
public int hashCode()
Description copied from class:NumberFormat
- Overrides:
hashCode
in classNumberFormat
-
readObject
private void readObject(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
clone
public java.lang.Object clone()
Description copied from class:NumberFormat
Overrides clone.- Overrides:
clone
in classNumberFormat
-
-