My XMPP server uses the older date format (JEP-0082), so I get parse Exceptions in the DelayInformationProvider class. Here’'s my workaround. Any chance of getting support for both date formats pushed into the smack lib.
Here’'s my workaround class:
public class DelayInformationProvider2 implements PacketExtensionProvider
{
public static final SimpleDateFormat UTC_FORMAT2 = new SimpleDateFormat(“yyyy-MM-dd’‘T’'HH:mm:ss”);
/**
-
Creates a new DeliveryInformationProvider.
-
ProviderManager requires that every PacketExtensionProvider has a public, no-argument constructor
*/
public DelayInformationProvider2()
{
}
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
{
DelayInformation.UTC_FORMAT.setTimeZone(TimeZone.getTimeZone(“GMT+0”));
DelayInformationProvider2.UTC_FORMAT2.setTimeZone(TimeZone.getTimeZone(“GMT+0”) );
Date stamp = null;
String attribute = parser.getAttributeValue("", “stamp”);
try
{
stamp = DelayInformation.UTC_FORMAT.parse(attribute);
}
catch ( ParseException ex )
{
// Try JEP-0082 style date.
stamp = DelayInformationProvider2.UTC_FORMAT2.parse(attribute);
}
DelayInformation delayInformation = new DelayInformation(stamp);
delayInformation.setFrom(parser.getAttributeValue("", “from”));
delayInformation.setReason(parser.nextText());
return delayInformation;
}
}
Or is there a better way to do this?
Thanks!
– Rob