如何在阿拉伯语语言环境中以简单日期格式解析日期?
我有来自服务器的日期 &格式为 = "2013-01-20T16:48:43" 我的应用程序支持阿拉伯语和英语语言环境.但是当我将语言环境更改为阿拉伯语时,日期没有解析它给我解析异常.到现在为止我写的是
i have date coming from server & is in the format = "2013-01-20T16:48:43" my application support Both Arabic & English Locale. But when i change the locale to Arabic the date is not parsing its giving me parse exception. till now what i have written is
private static Date parseJsonDate(final String string) throws Exception
{
final String change_Locale = Locale.getDefault().getISO3Language();
if (change_Locale.equalsIgnoreCase("ara"))
{
System.out.println(":: Date :::" + string);
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", new Locale("ar"));
System.out.println("new date " + format.parse(string));
return format.parse(string);
推荐答案
不要将你的日期解析成阿拉伯语,它会一直给你错误,除了尝试如下设置 Locale ENGLISH.
Do not parse your date into the Arabic it will give you error alwayz besides try as below by setting the Locale ENGLISH only.
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
相关文章