0

I'm using the following code to get the days of the current week

    DateFormat format = new SimpleDateFormat("EEEE yyyy/MM/dd");
    Calendar calendar = Calendar.getInstance();
    calendar.setFirstDayOfWeek(Calendar.MONDAY);
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);

    String[] days = new String[7];
    for (int i = 0; i < 7; i++)
    {
        days[i] = format.format(calendar.getTime());
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    }

    for (int i = 0; i < 7; i++)
    {
    System.out.println("days of week: "+days[i]);
    }

it gives me the days and dates ok, but I want them in arabic, what is the code to do this?

Thanks in Advance.

4

1 回答 1

3

在 SimpleDateFormat 的构造函数中,您可以传入语言环境。新的 SimpleDateFormat(字符串模板,区域设置语言环境);将其设置为任何一种以阿拉伯语为基础的语言都应该可以解决问题。

更新:正是:

//  Arabic available since 2.3
DateFormat format = new SimpleDateFormat("EEEE yyyy/MM/dd", new Locale("ar"));
于 2013-03-24T09:10:24.017 回答