Class Time
- java.lang.Object
-
- org.jivesoftware.smack.packet.Stanza
-
- org.jivesoftware.smack.packet.IQ
-
- org.jivesoftware.smackx.time.packet.Time
-
- All Implemented Interfaces:
Element
,FullyQualifiedElement
,IqView
,NamedElement
,StanzaView
,TopLevelStreamElement
,XmlLangElement
public class Time extends IQ
A Time IQ packet, which is used by XMPP clients to exchange their respective local times. Clients that wish to fully support the entity time protocol should register a PacketListener for incoming time requests that then respond with the local time.- See Also:
- XEP-202
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ
IQ.IQChildElementXmlStringBuilder, IQ.ResponseType, IQ.Type
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ELEMENT
static java.lang.String
NAMESPACE
-
Fields inherited from class org.jivesoftware.smack.packet.IQ
IQ_ELEMENT, QUERY_ELEMENT
-
Fields inherited from class org.jivesoftware.smack.packet.Stanza
DEFAULT_LANGUAGE, ITEM, language, TEXT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Time
createResponse(IQ request)
protected IQ.IQChildElementXmlStringBuilder
getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder buf)
This method must be overwritten by IQ subclasses to create their child content.java.util.Date
getTime()
Returns the local time ornull
if the time hasn't been set.java.lang.String
getTzo()
Returns the time zone.java.lang.String
getUtc()
Returns the time as a UTC formatted String using the format CCYY-MM-DDThh:mm:ssZ.void
setTime(java.util.Date time)
Sets the time using the local time.void
setTzo(java.lang.String tzo)
Sets the time zone offset.void
setUtc(java.lang.String utc)
Sets the time using UTC formatted String in the format CCYY-MM-DDThh:mm:ssZ.-
Methods inherited from class org.jivesoftware.smack.packet.IQ
createErrorResponse, createErrorResponse, createErrorResponse, createResultIQ, getChildElementName, getChildElementNamespace, getChildElementQName, getChildElementXML, getElementName, getType, setType, toString, toXML
-
Methods inherited from class org.jivesoftware.smack.packet.Stanza
addCommonAttributes, addExtension, addExtensions, appendErrorIfExists, getDefaultLanguage, getError, getExtension, getExtension, getExtension, getExtensionElement, getExtensions, getExtensions, getExtensions, getExtensions, getExtensionsMap, getFrom, getLanguage, getNamespace, getStanzaId, getTo, hasExtension, hasExtension, hasStanzaIdSet, logCommonAttributes, overrideExtension, removeExtension, removeExtension, setError, setError, setFrom, setLanguage, setNewStanzaId, setStanzaId, setStanzaId, setTo, throwIfNoStanzaId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jivesoftware.smack.packet.FullyQualifiedElement
getQName
-
Methods inherited from interface org.jivesoftware.smack.packet.IqView
isRequestIQ, isResponseIQ
-
Methods inherited from interface org.jivesoftware.smack.packet.StanzaView
getError, getExtension, getExtension, getExtensions, getExtensions, getExtensions, getFrom, getStanzaId, getTo, hasExtension, hasExtension, hasExtension
-
-
-
-
Field Detail
-
NAMESPACE
public static final java.lang.String NAMESPACE
- See Also:
- Constant Field Values
-
ELEMENT
public static final java.lang.String ELEMENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTime
public java.util.Date getTime()
Returns the local time ornull
if the time hasn't been set.- Returns:
- the local time.
-
setTime
public void setTime(java.util.Date time)
Sets the time using the local time.- Parameters:
time
- the current local time.
-
getUtc
public java.lang.String getUtc()
Returns the time as a UTC formatted String using the format CCYY-MM-DDThh:mm:ssZ.- Returns:
- the time as a UTC formatted String.
-
setUtc
public void setUtc(java.lang.String utc)
Sets the time using UTC formatted String in the format CCYY-MM-DDThh:mm:ssZ.- Parameters:
utc
- the time using a formatted String.
-
getTzo
public java.lang.String getTzo()
Returns the time zone.- Returns:
- the time zone.
-
setTzo
public void setTzo(java.lang.String tzo)
Sets the time zone offset.- Parameters:
tzo
- the time zone offset.
-
createResponse
public static Time createResponse(IQ request)
-
getIQChildElementBuilder
protected IQ.IQChildElementXmlStringBuilder getIQChildElementBuilder(IQ.IQChildElementXmlStringBuilder buf)
Description copied from class:IQ
This method must be overwritten by IQ subclasses to create their child content. It is important you don't use the builder to add the final end tag. This will be done automatically byIQ.IQChildElementXmlStringBuilder
after eventual existingExtensionElement
s have been added.For example to create an IQ with a extra attribute and an additional child element
<iq to='foo@example.org' id='123'> <bar xmlns='example:bar' extraAttribute='blaz'> <extraElement>elementText</extraElement> </bar> </iq>
getIQChildElementBuilder
looks like// The builder 'xml' will already have the child element and the 'xmlns' attribute added // So the current builder state is "<bar xmlns='example:bar'" xml.attribute("extraAttribute", "blaz"); xml.rightAngleBracket(); xml.element("extraElement", "elementText"); // Do not close the 'bar' attribute by calling xml.closeElement('bar')
xml.attribute("myAttribute", "myAttributeValue"); xml.setEmptyElement();
If your IQ does not contain any attributes or child elements (besidesExtensionElement
s), consider sub-classingSimpleIQ
instead.- Specified by:
getIQChildElementBuilder
in classIQ
- Parameters:
buf
- a pre-created builder which already has the child element and the 'xmlns' attribute set.- Returns:
- the build to create the IQ child content.
-
-