Java SimpleDateFormat create from Locale and custom format

Description

Java SimpleDateFormat create from Locale and custom format

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

public class Main {
  public static void main(String[] args) throws Exception {
    Locale currentLocale = new Locale("en", "US");
    SimpleDateFormat formatter = new SimpleDateFormat("EEE d MMM yy", currentLocale);
    Date today = new Date();
    String result = formatter.format(today);

    System.out.println("Locale: " + currentLocale.toString());
    System.out.println("Result: " + result);

  }/*  w  ww.  j  av  a  2 s . c  o m*/
}



PreviousNext

Related