Class DateNumberFormat

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    public final class DateNumberFormat
    extends NumberFormat
    See Also:
    Serialized Form
    • Field Detail

      • digits

        private char[] digits
      • zeroDigit

        private char zeroDigit
      • minusSign

        private char minusSign
      • positiveOnly

        private boolean positiveOnly
      • decimalBuf

        private transient char[] decimalBuf
      • maxIntDigits

        private int maxIntDigits
      • minIntDigits

        private int minIntDigits
    • Constructor Detail

      • DateNumberFormat

        public DateNumberFormat​(ULocale loc,
                                java.lang.String digitString,
                                java.lang.String nsName)
      • DateNumberFormat

        public DateNumberFormat​(ULocale loc,
                                char zeroDigit,
                                java.lang.String nsName)
    • 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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        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 class NumberFormat
        Parameters:
        obj - the object to compare against
        Returns:
        true if the object is equal to this.
      • readObject

        private void readObject​(java.io.ObjectInputStream stream)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException