Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 262
Buddhi Avatar asked Sep 27 '11 05:09

Buddhi


People also ask

Which date format does Java use?

The DateFormat class in Java is used for formatting dates. A specified date can be formatted into the Data/Time string. For example, a date can be formatted into: mm/dd/yyyy.

How do you check if the date is in YYYY MM DD format in Java?

SimpleDateFormat – yyyy-M-d For legacy Java application, we use SimpleDateFormat and . setLenient(false) to validate a date format.

What is TZ format date?

This format is defined by the sensible practical standard, ISO 8601. The T separates the date portion from the time-of-day portion. The Z on the end means UTC (that is, an offset-from-UTC of zero hours-minutes-seconds). The Z is pronounced “Zulu”.

What is format mmm dd yyyy?

MMM/DD/YYYY. Three-letter abbreviation of the month, separator, two-digit day, separator, four-digit year (example: JUL/25/2003) YY/DDD. Last two digits of year, separator, three-digit Julian day (example: 99/349)


1 Answers

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.

like image 65
BalusC Avatar answered Sep 28 '22 05:09

BalusC