What is the difference between MessageFormat.format and String.format in JDK 1.5?

前端 未结 2 1714
离开以前
离开以前 2020-12-23 18:33

What is the difference between MessageFormat.format and String.format in JDK 1.5?

2条回答
  •  一整个雨季
    2020-12-23 19:23

    String.format is just a shortcut to Formatter, this is a "printf-style" formatter. On the other side, MessageFormat uses a different formatting convention, as described in the linked documentation.

    Use the first "for layout justification and alignment, common formats for numeric, string, and date/time data, and locale-specific output" and the second "to produce concatenated messages in language-neutral way".

提交回复
热议问题