字符串格式的日期时间解析错误 [英] Date time parsing error from string format

查看:123
本文介绍了字符串格式的日期时间解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从保存在sharedpreferences中的字符串中获取日期格式。

I am trying to get the date format from a string which is saved in sharedpreferences.

如您所见图片中的日期错误。当前日期是2015年11月19日,但解析后更改为星期一7月11日...。请给我一些帮助。
谢谢。

As you can see the wrong date in the picture.current date is 19/11/2015 but after parsing it is changed to "Mon Jul 11 ..."something.please find some help for me. Thank you.

推荐答案

您从网络服务返回的dateobg为:2015年11月19日。

Your dateobg returning from web service is : 11-19-2015.

您尝试从此字符串获取日期,在这种情况下,应使用正确的SimpleDateFormat。

You try to get the date from this string, you should in this case use the correct SimpleDateFormat.

SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy", Locale.getDefault());

这篇关于字符串格式的日期时间解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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