AnsweredAssumed Answered

java.text.ParseException: Unparseable date

Question asked by Jan on Feb 23, 2015
Latest reply on Nov 11, 2016 by Tamal

Hi Flow,

 

For Offline messages our server adds this to every message:

<x xmlns='jabber:x:delay' stamp='20150223T14:18:31.135551'/>

 

but then smack library disconnects from the server and in print this to logcat:

 

02-23 17:15:58.514    4258-4610/**** W/AbstractXMPPConnection﹕ Connection closed with error

    org.jivesoftware.smack.SmackException: java.text.ParseException: Unparseable date: "20150223T14:18:31.135551" (at offset 8)

            at org.jivesoftware.smackx.delay.provider.AbstractDelayInformationProvider.parse(A bstractDelayInformationProvider.java:58)

            at org.jivesoftware.smackx.delay.provider.AbstractDelayInformationProvider.parse(A bstractDelayInformationProvider.java:29)

            at org.jivesoftware.smack.provider.Provider.parse(Provider.java:35)

            at org.jivesoftware.smack.util.PacketParserUtils.parsePacketExtension(PacketParser Utils.java:910)

            at org.jivesoftware.smack.util.PacketParserUtils.addPacketExtension(PacketParserUt ils.java:1016)

            at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.ja va:287)

            at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.jav a:151)

            at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMP PConnection.java:978)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$400(XMPPTCPConnection.java: 139)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:966)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:921)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:936)

            at java.lang.Thread.run(Thread.java:856)

     Caused by: java.text.ParseException: Unparseable date: "20150223T14:18:31.135551" (at offset 8)

            at java.text.DateFormat.parse(DateFormat.java:622)

            at org.jxmpp.util.XmppDateTime$DateFormatType.parse(XmppDateTime.java:112)

            at org.jxmpp.util.XmppDateTime.parseXEP0082Date(XmppDateTime.java:163)

            at org.jxmpp.util.XmppDateTime.parseDate(XmppDateTime.java:204)

            at org.jivesoftware.smackx.delay.provider.LegacyDelayInformationProvider.parseDate (LegacyDelayInformationProvider.java:33)

            at org.jivesoftware.smackx.delay.provider.AbstractDelayInformationProvider.parse(A bstractDelayInformationProvider.java:56)

            at org.jivesoftware.smackx.delay.provider.AbstractDelayInformationProvider.parse(A bstractDelayInformationProvider.java:29)

            at org.jivesoftware.smack.provider.Provider.parse(Provider.java:35)

            at org.jivesoftware.smack.util.PacketParserUtils.parsePacketExtension(PacketParser Utils.java:910)

            at org.jivesoftware.smack.util.PacketParserUtils.addPacketExtension(PacketParserUt ils.java:1016)

            at org.jivesoftware.smack.util.PacketParserUtils.parseMessage(PacketParserUtils.ja va:287)

            at org.jivesoftware.smack.util.PacketParserUtils.parseStanza(PacketParserUtils.jav a:151)

            at org.jivesoftware.smack.AbstractXMPPConnection.parseAndProcessStanza(AbstractXMP PConnection.java:978)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$400(XMPPTCPConnection.java: 139)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPC onnection.java:966)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPCon nection.java:921)

            at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnecti on.java:936)

            at java.lang.Thread.run(Thread.java:856)

 

I went through smack code and problem is in this pattern:

jxmpp/XmppDateTime.java at master · igniterealtime/jxmpp · GitHub

It does not match because our server adds milliseconds in timestamp

Outcomes