Java - date format with Turkish or other months

I want to format dates with month names with a localized label in different languages, including Turkish,

how to set formatted tags for months

+6
source share
2 answers

Use the SimpleDateFormat constructor by taking Locale .

 SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy", new Locale("tr")); String date = sdf.format(new Date()); System.out.println(date); // 27 Eylรผl 2011 

Locale accepts the ISO-639-1 language code .

+18
source
 public static void main(String Args[]) { String text = "ร‡ar, 11 Eyl 2013 19:28:14 +03:00"; try { Date sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss", new Locale("tr")).parse(text); SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String date = DATE_FORMAT.format(sdf); System.out.println(date); } catch (ParseException ex) { Logger.getLogger(test.class.getName()).log(Level.SEVERE, null, ex); } } 
0
source

Source: https://habr.com/ru/post/898127/