- Docs
- http://developer.android.com/reference/java/text/Format.html
- Classes
- Locale
- TimeZone
- Format
Convert objects or values, such as numeric values and dates, and their string representations.
In some cases these representations may be localized or contain localized characters or strings. For example, a numeric formatter such as DecimalFormat may convert a numeric value such as 12345 to the string "$12,345". It may also parse the string back into a numeric value. A date and time formatter like SimpleDateFormat may represent a specific date, encoded numerically, as a string such as "Wednesday, February 26, 1997 AD".
Many of the concrete subclasses of Format employ the notion of a pattern. A pattern is a string representation of the rules which govern the conversion between values and strings.
- NumberFormat
This class provides the interface for formatting and parsing numbers. - DecimalFormat
- ChoiceFormat
- MessageFormat
Produces concatenated messages in language-neutral way.
MessageFormat takes a set of objects, formats them and then inserts the formatted strings into the pattern at the appropriate places. eg:
- Object[] arguments = {
- Integer.valueOf(7), new Date(System.currentTimeMillis()),
- "a disturbance in the Force"};
- String result = MessageFormat.format(
- "At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",
- arguments);
-
- Output:
-
- At 12:30 PM on Jul 3, 2053, there was a disturbance in the Force on planet 7.
- Object[] arguments = {
- DateFormat
- SimpleDateFormat
- NumberFormat
- Currency
- xxx
- xxx