我正在尝试使用以下模式将此字符串“Tue Oct 07 03:00:00 EEST 2014”转换为日期对象: “E MMM dd HH:mm:ss Z yyyy”。我做错了什么?
最佳答案
您必须在此处使用区域设置。
例如:
String str = "Tue Oct 07 03:00:00 EEST 2014";
DateFormat df = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy", Locale.US);
System.out.println(df.parse(str));
输出:
Tue Oct 07 05:30:00 IST 2014
来自Java
doc .
SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. It allows for formatting (date -> text), parsing (text -> date), and normalization.
关于java - 无法转换 10 月 7 日星期二 :00:00 EEST 2014 to Date object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26377663/