Java Reference
In-Depth Information
Notice that
bundle
matches the
var
element from the configuration file and that
coun-
try
matches the key in the resource bundle.
Date and Number Formatting
Java programs use the
DateFormat.getDateInstance(int, locale)
to parse
and format dates in a locale-sensitive manner. Java programs use the
Number-
Format.get
XXX
Instance(locale)
method, where
XXX
can be
Currency
,
Number
, or
Percent
, to parse and format numerical values in a locale-sensitive manner.
An application can use date/time and number converters to format dates and numbers in a
locale-sensitive manner. For example, a shipping date could be converted as follows:
<h:outputText value="#{cashier.shipDate}">
<f:convertDateTime dateStyle="full"/>
</h:outputText>
For information on JavaServer Faces converters, see “Using the Standard Converters” in
The Java EE 6 Tutorial: Basic Concepts
.
Character Sets and Encodings
The following sections describe character sets and character encodings.
Character Sets
A
character set
is a set of textual and graphic symbols, each of which is mapped to a set
of nonnegative integers.
The first character set used in computing was US-ASCII. It is limited in that it can rep-
resent only American English. US-ASCII contains uppercase and lowercase Latin letters,
numerals, punctuation, control codes, and a few miscellaneous symbols.
Unicode defines a standardized, universal character set that can be extended to accom-
modate additions. When the Java program source file encoding doesn't support Unicode,
you can represent Unicode characters as escape sequences by using the notation
\u
XXXX
,
where
XXXX
is the character's 16-bit representation in hexadecimal. For example, the
Spanish version of the Duke's Tutoring message file uses Unicode for non-ASCII charac-
ters:
nav.main=P\u00e1gina Principal
nav.status=Mirar el estado
nav.current_session=Ver sesi\u00f3n actual del tutorial