Localizing Objects

Internationalize your beans by isolating locale-specific code and data.

  • Represent a locale using Java's Locale class.

  • Encapsulate locale-specific data in resource bundles.

Using Java's Locale Class

Java's Locale class represents a specific geographic, political, or cultural region. Create a Locale object for each locale you want represented. Locale objects do not encapsulate any data related to the locale represented.

The Locale class is part of the java.util package. Create a Locale object using one of the Locale class's two constructors.

Locale(String language, String country)
Locale(String language, String country, String variant)

Pass a String object encapsulating a special code representing the language you want encapsulated ...

Get JavaBeans Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.