How to get server time in XMPP SMACK library

631 views Asked by At

I know XEP-0202 in XMPP to get server utc time but I don't know how to use it with Android SMACK library to fetch server time in application.

Any idea ?

1

There are 1 answers

1
Umer Waqas On
public void GetServerTime(){
        if(xmppConnection!=null&&xmppConnection.isConnected())
            try {
                EntityTimeManager timeManager = EntityTimeManager.getInstanceFor(xmppConnection);
                String time = timeManager.getTime("SERVERDOMAIN").getUtc();
             Log.d("",""+time);
            }catch (Exception e){
                Log.d("",""+e);
            }


    }

while SERVERDOMAIN is your xmpp server url. which you add to make User JID i.e [email protected].

`

chat.xxmpp.com

` will be use as SERVERDOMAIN