powered by Jive Software

Date issue with DelayInformationProvider

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

Hey Rob,

That’‘s interesting. I didn’'t know that other date formats were being used. What do you think about being able to change the default date format used by DelayInformation? So you can no only change parsing delayed dates but also sending delayed dates.

Try using tomorrow’'s nightly build where you will find that DelayInformation.UTC_FORMAT can be modified.

Regards,

– Gato

Many Thanks, I’'ll give it a try and reply if I have any problems.

– Rob