public class Time extends IQ
// Request the time from a remote user. Time timeRequest = new Time(); timeRequest.setType(IQ.Type.GET); timeRequest.setTo(someUser@example.com); // 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 JEP-90. Because this is a non-standard protocol, it is subject to change.
ID_NOT_AVAILABLE
Constructor and Description |
---|
Time()
Creates a new Time instance with empty values for all fields.
|
Time(java.util.Calendar cal)
Cretaes a new Time instance using the specified calendar instance as
the time value to send.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getChildElementXML()
Returns the sub-element XML section of the IQ packet, or null if there
isn't one.
|
java.lang.String |
getDisplay()
Returns the local (non-utc) time in human-friendly format.
|
java.util.Date |
getTime()
Returns the local time or null if the time hasn't been set.
|
java.lang.String |
getTz()
Returns the time zone.
|
java.lang.String |
getUtc()
Returns the time as a UTC formatted String using the format CCYYMMDDThh:mm:ss.
|
void |
setDisplay(java.lang.String display)
Sets the local time in human-friendly format.
|
void |
setTime(java.util.Date time)
Sets the time using the local time.
|
void |
setTz(java.lang.String tz)
Sets the time zone.
|
void |
setUtc(java.lang.String utc)
Sets the time using UTC formatted String in the format CCYYMMDDThh:mm:ss.
|
addExtension, deleteProperty, getError, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, removeExtension, setError, setFrom, setPacketID, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setTo
public Time()
public Time(java.util.Calendar cal)
cal
- the time value.public java.util.Date getTime()
public void setTime(java.util.Date time)
time
- the current local time.public java.lang.String getUtc()
public void setUtc(java.lang.String utc)
utc
- the time using a formatted String.public java.lang.String getTz()
public void setTz(java.lang.String tz)
tz
- the time zone.public java.lang.String getDisplay()
public void setDisplay(java.lang.String display)
display
- the local time in human-friendly format.public java.lang.String getChildElementXML()
IQ
Extensions of this class must override this method.
getChildElementXML
in class IQ
Copyright © 2003 Jive Software.