更新时间:2023-11-05 17:25:34
我认为您的日期格式没有意义.没有 13:00 PM.删除格式末尾的aaa"或将 HH 变成 hh.
I think your date format does not make sense. There is no 13:00 PM. Remove the "aaa" at the end of your format or turn the HH into hh.
尽管如此,这对我来说很好用:
Nevertheless, this works fine for me:
String testDate = "29-Apr-2010,13:00:14 PM";
DateFormat formatter = new SimpleDateFormat("d-MMM-yyyy,HH:mm:ss aaa");
Date date = formatter.parse(testDate);
System.out.println(date);
它会打印Thu Apr 29 13:00:14 CEST 2010".
It prints "Thu Apr 29 13:00:14 CEST 2010".