Documentation

The Java™ Tutorials
Hide TOC
Formatting
Trail: Internationalization

Lesson: Formatting课程:格式化

This lesson explains how to format numbers, currencies, dates, times, and text messages. 本课介绍如何设置数字、货币、日期、时间和短信的格式。Because end users can see these data elements, their format must conform to various cultural conventions. 因为最终用户可以看到这些数据元素,所以它们的格式必须符合各种文化习俗。Following the examples in this lesson will teach you how to:以下是本课程中的示例,将教您如何:

Numbers and Currencies数字和货币

This section explains how to use the NumberFormat, DecimalFormat, and DecimalFormatSymbols classes.本节介绍如何使用NumberFormatDecimalFormatDecimalFormatSymbols类。

Dates and Times日期和时间


Version note:版本说明: This Date and Time section uses the date and time APIs in the java.util package. 这个日期和时间部分使用java.util包中的日期和时间API。The java.time APIs, available in the JDK 8 release, provides a comprehensive date and time model that offers significant improvements over the java.util classes. JDK 8发行版中提供的javatime API提供了一个全面的日期和时间模型,与java.util类相比有显著的改进。The java.time APIs are described in the Date Time trail. java.time API在日期时间跟踪中进行了描述。The Legacy Date-Time Code page might be of particular interest. 遗留日期时间代码页可能会引起特别的兴趣。

This section focuses on the DateFormat, SimpleDateFormat, and DateFormatSymbols classes.本节重点介绍DateFormatSimpleDateFormatDateFormatSymbols类。

Messages消息

This section shows how the MessageFormat and ChoiceFormat classes can help you solve some of the problems you might encounter when formatting text messages.本节介绍MessageFormatChoiceFormat类如何帮助您解决格式化文本消息时可能遇到的一些问题。


Previous page: Previous Lesson
Next page: Numbers and Currencies