0

我想要一个 SimpleDateFormat 允许我以这种方式显示日期:

Lunes, 03/09/2012 a las 9:59 

(Lunes 在西班牙语中是星期一的意思)

是否有一个字符串可以用来构建这样的 SimpleDateFormat 还是必须手动操作 Date?

4

2 回答 2

2

也许是这样的?

    Locale locale = new Locale("es", "ES");
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE, dd/MM/yyyy 'a las' HH:mm", locale);
    System.out.println(sdf.format(new Date()));

结果:

卢恩斯,2012 年 3 月 9 日上午 10:26

于 2012-09-03T08:26:26.893 回答
0

试试这个。

 Locale locale = new Locale("es", "ES");
 Log.i("Current Date :: ",getCurrentDate("EEEE, dd/MM/yyyy 'a las' hh:mm",locale));

public static String getCurrentDate(String dateFormat,Locale locale)
{
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(dateFormat,locale);
    return sdf.format(cal.getTime());
}

Current Date :: lunes, 03/09/2012 a las 01:52
于 2012-09-03T08:24:04.480 回答