Using the Locale.Category enumeration to display information using two different locales
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Locale;
public class Test {
public static void main(String[] args) {
Locale locale = Locale.getDefault();
Calendar calendar = Calendar.getInstance();
calendar.setWeekDate(2012, 16, 3);
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 examples in the same category