Java Format - Java SimpleDateFormat(String pattern, Locale locale) Constructor








Syntax

SimpleDateFormat(String pattern, Locale locale) constructor from SimpleDateFormat has the following syntax.

public SimpleDateFormat(String pattern,     Locale locale)

Example

In the following code shows how to use SimpleDateFormat.SimpleDateFormat(String pattern, Locale locale) constructor.

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/*from ww w  .  java 2s.  co m*/
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);

  }
}

The code above generates the following result.