2
我已检查此网站和网络的解决方案,但没有结果。 我一直在寻找遍布全球的日期格式问题解决方案。我有我想转换成日期格式如下字符串:日期格式和解析问题
YYYYMMDD-HH:MM:SS.SSS
我的代码是:
String myTestString = "20111215-07:26:48.689";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH:mm:ss.SSS", Locale.ENGLISH);
Date d = null;
try{
d = sdf.parse(myTestString);
System.out.println(d);
}catch(ParseException pe){
pe.printStackTrace();
}
,但我得到:
java.text.ParseException: Unparseable date: "Fri Dec 16 15:48:42 GMT 2011"
at java.text.DateFormat.parse(DateFormat.java:337)
at TestClass.main(TestClass.java:54)
任何想法?
见http://stackoverflow.com/questions/2375222/java-simpledateformat-for-time-zone-with-a-colon-seperator – csl 2011-12-15 18:06:53
作为据我所知,上面的代码片段不可能给出上述结果。错误报告的不可解析字符串不是您的代码声明的字符串。 – 2011-12-15 18:12:08
好吧,我纠正了输出。请告诉我。谢谢! – Adnan 2011-12-16 15:50:19