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

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

问题描述

我有时间从服务器和放大器来了;在格式=2013-01-20T16:48:43我的应用程序同时支持阿拉伯语和放大器;英语语言环境。但是,当我的语言环境更改为阿拉伯语的日期不解析它给我解析异常。到现在我已经写的

 私有静态日期parseJsonDate(最终串串)抛出异常
    {
    最后弦乐change_Locale = Locale.getDefault()getISO3Language()。
            如果(change_Locale.equalsIgnoreCase(ARA))
            {

                的System.out.println(::日期:::+字符串);
                最后SimpleDateFormat的格式=新的SimpleDateFormat(YYYY-MM-dd'T'HH:MM:SS,新的语言环境(AR));

                的System.out.println(新日+ format.parse(字符串));
                返回format.parse(串);
 

解决方案

不解析你的约会到阿拉伯语,它会给你错误alwayz除了尝试如下只设置了语言环境英语。

 最后SimpleDateFormat的格式=新的SimpleDateFormat(YYYY-MM-dd'T'HH:MM:SS,Locale.ENGLISH);
 

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);

解决方案

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天全站免登陆