如何在阿拉伯语语言环境中以简单日期格式解析日期? [英] How to Parse date in Simple date format in arabic locale?

查看:24
本文介绍了如何在阿拉伯语语言环境中以简单日期格式解析日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有来自服务器的日期 &格式为 = "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);

这篇关于如何在阿拉伯语语言环境中以简单日期格式解析日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆