diff --git a/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java b/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java index 13e731fb7..2065af6fe 100644 --- a/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java +++ b/source/org/jivesoftware/smackx/provider/DelayInformationProvider.java @@ -26,18 +26,21 @@ import org.jivesoftware.smackx.packet.DelayInformation; import org.xmlpull.v1.XmlPullParser; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; +import java.util.TimeZone; /** * The DelayInformationProvider parses DelayInformation packets. - * + * * @author Gaston Dombiak */ public class DelayInformationProvider implements PacketExtensionProvider { /** * Creates a new DeliveryInformationProvider. - * ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor + * ProviderManager requires that every PacketExtensionProvider has a public, no-argument + * constructor */ public DelayInformationProvider() { } @@ -49,7 +52,15 @@ public class DelayInformationProvider implements PacketExtensionProvider { } catch (ParseException e) { // Try again but assuming that the date follows JEP-82 format // (Jabber Date and Time Profiles) - stamp = DelayInformation.NEW_UTC_FORMAT.parse(parser.getAttributeValue("", "stamp")); + try { + stamp = DelayInformation.NEW_UTC_FORMAT + .parse(parser.getAttributeValue("", "stamp")); + } catch (ParseException e1) { + // Last attempt. Try parsing the date assuming that it does not include milliseconds + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + formatter.setTimeZone(TimeZone.getTimeZone("UTC")); + stamp = formatter.parse(parser.getAttributeValue("", "stamp")); + } } DelayInformation delayInformation = new DelayInformation(stamp); delayInformation.setFrom(parser.getAttributeValue("", "from"));