A good date converter for Jalali Calendar in Java? [closed]

For better localization and language support, it is often convenient to use the ICU (International Components for Unicode) library from IBM.

The APIs are similar to the standard Java APIs, but add additional support for localization and internationalization (e.g. time and calendar issues, sorting, formatting rules and a regex implementation with proper Unicode support).

To create a Persian calendar and output the formatted date in Farsi, you would e.g. do something like this:

import com.ibm.icu.text.DateFormat;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.ULocale;

...

ULocale locale = new ULocale("fa_IR@calendar=persian");

Calendar calendar = Calendar.getInstance(locale);
DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, locale);

System.out.println(df.format(calendar));

This will output:

چهارشنبه ۱۰ اردیبهشت ۱۳۹۳ ه‍.ش.

Leave a Comment