Formatting and Parsing a Time for a Locale: specify the locale when creating the SimpleDateFormat object. : Date Format « I18N « Java






Formatting and Parsing a Time for a Locale: specify the locale when creating the SimpleDateFormat object.

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

public class Main {
  public static void main(String[] argv) throws Exception {

    Locale locale = Locale.FRENCH;

    DateFormat formatter = new SimpleDateFormat("HH:mm:ss zzzz", locale);
    String s = formatter.format(new Date());
    System.out.println(s);

  }
}

   
  








Related examples in the same category

1.Show DateShow Date
2.Simple Date formatSimple Date format
3.Java I18N: Format : Date FormatJava I18N: Format : Date Format
4.Java I18N: Format : Date Format Symbols DemoJava I18N: Format : Date Format Symbols Demo
5.Demonstrate number and date internationalizationDemonstrate number and date internationalization
6.Use some locales choicesUse some locales choices
7.Format some values using the default locale
8.Formatting and Parsing a Time for a Locale Using Default Formats
9.Formatting and Parsing a Date for a Locale: specify the locale when creating the SimpleDateFormat object.