|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jivesoftware.smack.packet.Packet
org.jivesoftware.smack.packet.IQ
org.jivesoftware.smackx.packet.Time
public class Time
A Time IQ packet, which is used by XMPP clients to exchange their respective local times. Clients that wish to fully support the entitity time protocol should register a PacketListener for incoming time requests that then respond with the local time. This class can be used to request the time from other clients, such as in the following code snippet:
// Request the time from a remote user. Time timeRequest = new Time(); timeRequest.setType(IQ.Type.GET); timeRequest.setTo(someUser@example.com/resource); // Create a packet collector to listen for a response. PacketCollector collector = con.createPacketCollector( new PacketIDFilter(timeRequest.getPacketID())); con.sendPacket(timeRequest); // Wait up to 5 seconds for a result. IQ result = (IQ)collector.nextResult(5000); if (result != null && result.getType() == IQ.Type.RESULT) { Time timeResult = (Time)result; // Do something with result... }
Warning: this is an non-standard protocol documented by XEP-0090. Because this is a non-standard protocol, it is subject to change.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ |
---|
IQ.Type |
Field Summary |
---|
Fields inherited from class org.jivesoftware.smack.packet.Packet |
---|
DEFAULT_LANGUAGE, ID_NOT_AVAILABLE |
Constructor Summary | |
---|---|
Time()
Creates a new Time instance with empty values for all fields. |
|
Time(Calendar cal)
Creates a new Time instance using the specified calendar instance as the time value to send. |
Method Summary | |
---|---|
String |
getChildElementXML()
Returns the sub-element XML section of the IQ packet, or null if there isn't one. |
String |
getDisplay()
Returns the local (non-utc) time in human-friendly format. |
Date |
getTime()
Returns the local time or null if the time hasn't been set. |
String |
getTz()
Returns the time zone. |
String |
getUtc()
Returns the time as a UTC formatted String using the format CCYYMMDDThh:mm:ss. |
void |
setDisplay(String display)
Sets the local time in human-friendly format. |
void |
setTime(Date time)
Sets the time using the local time. |
void |
setTz(String tz)
Sets the time zone. |
void |
setUtc(String utc)
Sets the time using UTC formatted String in the format CCYYMMDDThh:mm:ss. |
Methods inherited from class org.jivesoftware.smack.packet.IQ |
---|
getType, setType, toXML |
Methods inherited from class org.jivesoftware.smack.packet.Packet |
---|
addExtension, deleteProperty, equals, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, hashCode, nextID, parseXMLLang, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTo |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Time()
public Time(Calendar cal)
cal
- the time value.Method Detail |
---|
public Date getTime()
public void setTime(Date time)
time
- the current local time.public String getUtc()
public void setUtc(String utc)
utc
- the time using a formatted String.public String getTz()
public void setTz(String tz)
tz
- the time zone.public String getDisplay()
public void setDisplay(String display)
display
- the local time in human-friendly format.public String getChildElementXML()
IQ
Extensions of this class must override this method.
getChildElementXML
in class IQ
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |