powered by Jive Software

Time

I had some questions about time packets:

When I call Time#getTime() am I supposed to get returned my local time?

If so, how do I get the time of the remote user, which I thought was the desired behavior, do i get the utc string and parse it myself?

Thanks,

Alex

Here’‘s what I’'m doing

XMPPConnection con = BuddyList.getInstance().getConnection();

Time request = new Time();

request.setType(IQ.Type.GET);

request.setTo(dialog.getUser());

// Create a packet collector to listen for a response.

PacketCollector collector = con

.createPacketCollector(new PacketIDFilter(request.getPacketID()));

con.sendPacket(request);

collector.cancel();

// Wait up to 5 seconds for a result.

IQ result = (IQ) collector.nextResult(SmackConfiguration

.getPacketReplyTimeout());

if( dialog.cancelled ) return;

if (result != null && result.getType() == IQ.Type.RESULT) {

Time t = (Time) result;

field.setText(t.getDisplay());

} else

field.setText(“N/A”);

field.validate();

/code

where field is a JTextField. This shows the time of the remote user using their time format. Is this what you mean?

Yea, that works, I guess I just don’'t understand the getTime() method then. And it would also be nice to be able to format the time how i like it as well, a solution for that would be I guess would be to pull out the UTC and format that.

Thanks for the help!

Alex