无法使用SimpleDateFormat解析 [英] Can't parse using SimpleDateFormat

查看:86
本文介绍了无法使用SimpleDateFormat解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用MMM d HH:mm:ss解析Dec 6 04:13:01,但它不工作!我花了很多时间,但没有想出来。

I'm trying to parse "Dec 6 04:13:01" with "MMM d HH:mm:ss", but it is not working! I spent a lot of time but cant figure it out.

任何想法为什么失败?

推荐答案

您可能试图用 JAPANESE 语言环境(从您的个人资料+您的网页猜测)来解析它,例如指定任何英文语言环境: Locale.US

You are probably trying to parse it with JAPANESE locale (guessing it from your profile + your web page), specify any english locale for example: Locale.US

String dateString = "Dec 6 04:13:01";
DateFormat df = new SimpleDateFormat("MMM d HH:mm:ss", Locale.US);
System.out.println(df.parse(dateString));

这篇关于无法使用SimpleDateFormat解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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