Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8318761

MessageFormat pattern support for CompactNumberFormat, ListFormat, and DateTimeFormatter

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • None
    • core-libs
    • None
    • b12
    • generic
    • generic

      MessageFormat partially supports ListFormat, CompactNumberFormat, and DateTimeFormatter through the setter methods. However, MessageFormat does not support them via the pattern syntax. Both through applyPattern() and toPattern().

      The specification of toPattern() could also be improved, as it cannot produce patterns for the mentioned classes, as well as for any user-defined subclasses of Format. For example,

      MessageFormat first = new MessageFormat("{0}");
      first.setFormatByArgumentIndex(0, new ChoiceFormat("0#foo"));
      first.toPattern(); // returns "{0,choice,0.0#foo}"
      MessageFormat second = new MessageFormat("{0}");
      second.setFormatByArgumentIndex(0, NumberFormat.getCompactNumberInstance(second.getLocale(), NumberFormat.Style.SHORT));
      second.toPattern(); // returns "{0}"

            jlu Justin Lu
            jlu Justin Lu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: