为什么这个 SimpleDateFormat 不能解析这个日期字符串? [英] Why can't this SimpleDateFormat parse this date string?
本文介绍了为什么这个 SimpleDateFormat 不能解析这个日期字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
简单日期格式:
SimpleDateFormat pdf = new SimpleDateFormat("MM dd yyyy hh:mm:ss:SSSaa");
pdf.parse("Mar 30 2010 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.
推荐答案
月份:如果图案的数量字母为 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屋!
查看全文