Java examples for Internationalization:Locale
Creating Locales with Locale Builder
import java.text.DateFormat; import java.text.NumberFormat; import java.util.Date; import java.util.Locale; import java.util.Locale.Builder; public class Main { public static void main(String[] args) { System.out.printf("Creating from Builder...\n\n"); String[][] langRegions = { { "fr", "FR" }, { "ja", "JP" }, { "en", "US" } }; Builder builder = new Builder(); Locale l = null;//from w ww . j av a2 s. co m for (String[] lr : langRegions) { builder.clear(); builder.setLanguage(lr[0]).setRegion(lr[1]); l = builder.build(); displayLocalizedData(l, 123456789L, new Date()); } } private static void displayLocalizedData(Locale l, long number, Date date) { NumberFormat nf = NumberFormat.getInstance(l); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, l); System.out.printf("Locale: %s\nNumber: %s\nDate: %s\n\n", l.getDisplayName(), nf.format(number), df.format(date)); } }