Create Locales with Locale static constants - Java Internationalization

Java examples for Internationalization:Locale

Description

Create Locales with Locale static constants

Demo Code

import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.Date;
import java.util.Locale;

public class Main {
  public static void main(String[] a) {
    System.out.printf("Creating from ...\n\n");
    Locale[] locales = new Locale[]{Locale.FRANCE, Locale.JAPAN, Locale.US};        
    for (Locale l: locales) {
      displayLocalizedData(l, 123456789L, new Date());
    }       /* w  ww  .  ja v a  2  s.  c  o  m*/
    
  }

  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));
  }
}

Result


Related Tutorials