SimpleDateFormat and locale based format string
SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE dd MMM yyyy", Locale.ENGLISH);String formatted = dateFormat.format(the_date_you_want_here);
Use DateFormat.getDateInstance(int style, Locale locale) instead of creating your own patterns with SimpleDateFormat
.
Use the style + locale: DateFormat.getDateInstance(int style, Locale locale)
Check http://java.sun.com/j2se/1.5.0/docs/api/java/text/DateFormat.html
Run the following example to see the differences:
import java.text.DateFormat;import java.util.Date;import java.util.Locale;public class DateFormatDemoSO { public static void main(String args[]) { int style = DateFormat.MEDIUM; //Also try with style = DateFormat.FULL and DateFormat.SHORT Date date = new Date(); DateFormat df; df = DateFormat.getDateInstance(style, Locale.UK); System.out.println("United Kingdom: " + df.format(date)); df = DateFormat.getDateInstance(style, Locale.US); System.out.println("USA: " + df.format(date)); df = DateFormat.getDateInstance(style, Locale.FRANCE); System.out.println("France: " + df.format(date)); df = DateFormat.getDateInstance(style, Locale.ITALY); System.out.println("Italy: " + df.format(date)); df = DateFormat.getDateInstance(style, Locale.JAPAN); System.out.println("Japan: " + df.format(date)); }}
Output:
United Kingdom: 25-Sep-2017USA: Sep 25, 2017France: 25 sept. 2017Italy: 25-set-2017Japan: 2017/09/25