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/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.
DEFAULT_LANGUAGE, ID_NOT_AVAILABLE| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
createErrorResponse, createResultIQ, getType, setType, toXMLaddExtension, deleteProperty, equals, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, hashCode, nextID, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTopublic Time()
public Time(Calendar cal)
cal - the time value.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()
IQExtensions of this class must override this method.
getChildElementXML in class IQCopyright © 2003-2007 Jive Software.