New locales in Java 6 : New Locales « JDK 6 « Java






New locales in Java 6

 
/*
Language                  Country         Locale Identifier
Chinese (Simplified)      Singapore       zh_SG
English                   Malta           en_MT
English                   Philippines     en_PH
English                   Singapore       en_SG
Greek                     Cyprus          el_CY
Indonesian                Indonesia       in_ID
Japanese (Japanese calendar)  Japan       ja_JP_JP
Malay                     Malaysia        ms_MY
Maltese                   Malta           mt_MT
Spanish                   US              es_US
*/

import java.text.DateFormat;
import java.util.Calendar;
import java.util.Locale;

import javax.swing.JOptionPane;

public class JapaneseCalendar {
  public static void main(String[] args) {
    Locale japanese = new Locale("ja", "JP", "JP");

    Calendar cal = Calendar.getInstance(japanese);
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, japanese);
    String str = df.format(cal.getTime());

    JOptionPane.showMessageDialog(null, str);
  }
}

        








Related examples in the same category

1.Locale Sensitive Services SPI
2.Displaying Calendar Names
3.Japanese Imperial Calendar