小编典典

java.text.ParseException:无法分析的日期:“ 2005年8月22日星期一20:21:52 +0200”

java

我得到这个错误。

我的代码有什么问题?

String line = "Date: Mon, 22 Aug 2005 20:21:52 +0200";
String datestring = line.substring(6);
DateFormat dateFormat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss ZZZZZ");
Date inputDate = null;

try {
    inputDate = dateFormat.parse(datestring);
} catch (ParseException e) {
    e.printStackTrace();
}

我的错误日志:

java.text.ParseException:无法解析的日期:netspy.EMail.parseLine(EMail.java:133)的java.text.DateFormat.parse(未知来源)为“
Mon,22 Aug 2005 20:21:52 +0200”
netspy.FileManager上的.EMail.parseMail(EMail.java:91).netspy.BaseFrame.switchContent(BaseFrame.java:218)上的netspy.FileManager.findMails(FileManager.java:66)在netspy.BaseListener.actionPerformed(BaseListener.java:79)在javax.swing.DefaultButtonModel.setPressed(未知源)在javax.swing.DefaultButtonModel.fireActionPerformed(未知源)在javax.swing.AbstractButton
$
Handler.actionPerformed(未知源)在javax.swing.DefaultButtonModel.fireActionPerformed(未知源)在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(未知源)处,在javax.java.awt.Component.processMouseEvent(未知源)处。在java.awt.Component.processEvent(未知源)的swing.JComponent.processMouseEvent(未知源)在java.awt处的java.awt.Component.dispatchEventImpl(未知源)的java.awt.Container.processEvent(未知源)。
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
Source)的java.awt.LightweightDispatcher.remouseEvent(Unknown
Source)的java.awt.LightweightDispatcher.processMouseEvent(Unknown
Source)的java.awt.LightweightDispatcher处的Container.dispatchEventImpl(Unknown
Source)。
java.awt.Container.dispatchEventImpl的dispatchEvent(未知源)java.awt.Window.dispatchEventImpl的java.awt.Component.dispatchEventImpl(未知源)的java.awt.EventQueue.dispatchEventImpl(未知源)
java.awt.EventQueue.access $ 400中的Unknown Source)(java.awt中的Unknown
Source)。EventQueue $ 3.run(未知源),java.awt.EventQueue $
3.run(未知源),java.security.AccessController.doPrivileged(本机方法),java.security.ProtectionDomain
$ 1.doIntersectionPrivilege(未知源),java.security .ProtectionDomain $
1.doIntersectionPrivilege(未知源)在java.awt.EventQueue $
4.run(未知源)在java.awt.EventQueue $
4.run(在java.security.AccessController.doPrivileged(本机方法)处)。
security.ProtectionDomain $
1.doIntersectionPrivilege(未知源)在java.awt.EventQueue.dispatchEvent(未知源)在java.awt.EventDispatchThread.pumpOneEventForFilters(未知源)在java.awt.EventDispatchThread.pumpEventsForFilter(未知源)
.EventDispatchThread.pumpEventsForHierarchy(未知源),位于java.awt。java.awt.EventDispatchThread.pumpEvents(未知源)处的java.awt.EventDispatchThread.run中的EventDispatchThread.pumpEvents(未知源)(未知源)


阅读 350

收藏
2020-11-30

共1个答案

小编典典

您的系统语言环境不是英语吗?尝试明确指定语言环境:

DateFormat dateFormat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss ZZZZZ",
        Locale.US);
2020-11-30