Java中的简单日期格式,解析异常 [英] Simple date format in java, Parse Exception

查看:557
本文介绍了Java中的简单日期格式,解析异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的日期字符串:07SEP2014 00:00

here is my date String : "07SEP2014 00:00"

这是将字符串转换为日期的代码:简单数据格式(ddMMMyyyy HH:mm)。parse(dateString);

and this is the code that convert string to date :

new SimpleDateFormat("ddMMMyyyy HH:mm").parse(dateString);

我正在解析异常。我正在做错什么?

and i'm getting parse exception. What i'm doing wrong?

推荐答案

您的代码可以工作 - 只要您的系统具有SEP = 9月的区域设置。
您可以设置区域设置以确保:

Your Code works - as long as your System has a Locale where SEP = September. You could set the Locale to be sure about that:

Date result = new SimpleDateFormat("ddMMMyyyy HH:mm",Locale.ENGLISH).parse(dateString);

这篇关于Java中的简单日期格式,解析异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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