Using the Locale.Category enumeration to display information - Java Internationalization

Java examples for Internationalization:Locale

Description

Using the Locale.Category enumeration to display information

Demo Code

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

public class Main {

  public static void main(String[] args) {
    Locale locale = Locale.getDefault();
    Calendar calendar = Calendar.getInstance();
    calendar.setWeekDate(2012, 16, 3);/*from ww  w  . j  a v a 2 s. co m*/

    System.out.println(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println(locale.getDisplayLanguage());

    Locale.setDefault(Locale.Category.FORMAT, Locale.JAPANESE);
    Locale.setDefault(Locale.Category.DISPLAY, Locale.GERMAN);

    System.out.println(DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(calendar.getTime()));
    System.out.println(locale.getDisplayLanguage());

  }

}

Related Tutorials