javadatelocalizationformatting

Java - Date format with Turkish or other months


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

how do I set formatted labels for months


Solution

  • Use the SimpleDateFormat constructor taking a 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
    

    The Locale accepts an ISO-639-1 language code.