mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-29 17:52:06 +01:00
Added new attempt to parse the date. SMACK-67
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2523 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
69c86bbeec
commit
ebeedc148c
1 changed files with 14 additions and 3 deletions
|
@ -26,7 +26,9 @@ import org.jivesoftware.smackx.packet.DelayInformation;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The DelayInformationProvider parses DelayInformation packets.
|
* The DelayInformationProvider parses DelayInformation packets.
|
||||||
|
@ -37,7 +39,8 @@ public class DelayInformationProvider implements PacketExtensionProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new DeliveryInformationProvider.
|
* 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() {
|
public DelayInformationProvider() {
|
||||||
}
|
}
|
||||||
|
@ -49,7 +52,15 @@ public class DelayInformationProvider implements PacketExtensionProvider {
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
// Try again but assuming that the date follows JEP-82 format
|
// Try again but assuming that the date follows JEP-82 format
|
||||||
// (Jabber Date and Time Profiles)
|
// (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 delayInformation = new DelayInformation(stamp);
|
||||||
delayInformation.setFrom(parser.getAttributeValue("", "from"));
|
delayInformation.setFrom(parser.getAttributeValue("", "from"));
|
||||||
|
|
Loading…
Reference in a new issue