Messages date/time

Where can I get the sent date/time of a Message Packet with Smack API?

I could not find any information about that in the JavaDoc.

A packet is either received in near real time, or it will contain delay extension containing the time of originally sent : http://www.xmpp.org/extensions/xep-0091.html

-Pony

Have you tried extracting the Timestamp variable from the packet?

I don’t see any of this attribute in the Packet or Message class.

Here is an example of a packet with a delay “extension”:

<message id=“YepE1-66” to="keith.lirette@jabber.com/TransVerse" xml:lang=“en” type=“groupchat” from="wbtest_1@conference.jabber.com/michael.bishop"><body xml:lang=“en”>Did you get the report?</body><x xmlns=“jabber:x:delay” stamp=“20070713T15:39:28” from="michael.bishop@jabber.com/TransVerse"/></message>

Look at the DelayInformation class in the Smack javadocs.

-Pony

This is the code I use to get the date/time from a message packet:

public static Date getTimestamp(Packet packet) {

DelayInformation delay = (DelayInformation) packet.getExtension(“x”, “jabber:x:delay”);

if (delay != null) {

return delay.getStamp();

}

return null;

}

Chris