mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Improved parsing of date considering JEP-82 format. SMACK-67
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2516 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
1ce0be62d0
commit
34baa2545b
2 changed files with 24 additions and 5 deletions
|
@ -20,14 +20,14 @@
|
|||
|
||||
package org.jivesoftware.smackx.provider;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smackx.packet.DelayInformation;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The DelayInformationProvider parses DelayInformation packets.
|
||||
*
|
||||
|
@ -43,8 +43,14 @@ public class DelayInformationProvider implements PacketExtensionProvider {
|
|||
}
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
DelayInformation.UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||
Date stamp = DelayInformation.UTC_FORMAT.parse(parser.getAttributeValue("", "stamp"));
|
||||
Date stamp = null;
|
||||
try {
|
||||
stamp = DelayInformation.UTC_FORMAT.parse(parser.getAttributeValue("", "stamp"));
|
||||
} 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"));
|
||||
}
|
||||
DelayInformation delayInformation = new DelayInformation(stamp);
|
||||
delayInformation.setFrom(parser.getAttributeValue("", "from"));
|
||||
delayInformation.setReason(parser.nextText());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue