为什么SimpleDateFormat不能解析这个日期字符串? [英] Why can't this SimpleDateFormat parse this date string?

查看:160
本文介绍了为什么SimpleDateFormat不能解析这个日期字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SimpleDateFormat:

The SimpleDateFormat:

SimpleDateFormat pdf = new SimpleDateFormat("MM dd yyyy hh:mm:ss:SSSaa");

pdf.parse抛出的异常(2010年3月30日5:27 :40:140PM);

java.text.ParseException: Unparseable date: "Mar 30 2010 5:27:40:140PM"

任何想法?

编辑:感谢您的快速回答。你都是正确的,我只想错过SimpleDateFormat文档中的一个关键句子 - 我应该可以称之为一天。

thanks for the fast answers. You were all correct, I just missed that one key sentence in the SimpleDateFormat docs - I should probably call it a day.

推荐答案

SimpleDateFormat javadocs


月份:如果模式
字母的数量为3或以上,则该月份为
解释为文本;

Month: If the number of pattern letters is 3 or more, the month is interpreted as text; otherwise, it is interpreted as a number.

尝试使用像MMM dd yyyy这样的模式

Try to use pattern like "MMM dd yyyy"

这篇关于为什么SimpleDateFormat不能解析这个日期字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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