本文整理匯總了Java中org.jivesoftware.smackx.time.packet.Time類的典型用法代碼示例。如果您正苦於以下問題:Java Time類的具體用法?Java Time怎麽用?Java Time使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Time類屬於org.jivesoftware.smackx.time.packet包,在下文中一共展示了Time類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: EntityTimeManager
import org.jivesoftware.smackx.time.packet.Time; //導入依賴的package包/類
private EntityTimeManager(XMPPConnection connection) {
super(connection);
if (autoEnable)
enable();
connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, Type.get,
Mode.async) {
@Override
public IQ handleIQRequest(IQ iqRequest) {
if (enabled) {
return Time.createResponse(iqRequest);
}
else {
return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.not_acceptable));
}
}
});
}
示例2: enable
import org.jivesoftware.smackx.time.packet.Time; //導入依賴的package包/類
public synchronized void enable() {
if (enabled)
return;
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
sdm.addFeature(Time.NAMESPACE);
enabled = true;
}
示例3: disable
import org.jivesoftware.smackx.time.packet.Time; //導入依賴的package包/類
public synchronized void disable() {
if (!enabled)
return;
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection());
sdm.removeFeature(Time.NAMESPACE);
enabled = false;
}
示例4: getTime
import org.jivesoftware.smackx.time.packet.Time; //導入依賴的package包/類
public Time getTime(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
if (!isTimeSupported(jid))
return null;
Time request = new Time();
Time response = (Time) connection().createPacketCollectorAndSend(request).nextResultOrThrow();
return response;
}
示例5: parseTimeWithIntrospectionTest
import org.jivesoftware.smackx.time.packet.Time; //導入依賴的package包/類
@Test
public void parseTimeWithIntrospectionTest() throws Exception {
// @formatter:off
final String request =
"<iq type='get'"
+ "from='[email protected]/orchard'"
+ "to='[email protected]/balcony'"
+ "id='time_1'>"
+ "<time xmlns='urn:xmpp:time'/>"
+ "</iq>";
// @formatter:on
IQ iqRequest = (IQ) PacketParserUtils.parseStanza(request);
assertTrue(iqRequest instanceof Time);
// @formatter:off
final String response =
"<iq type='result'"
+ "from='[email protected]/balcony'"
+ "to='[email protected]/orchard'"
+ "id='time_1'>"
+ "<time xmlns='urn:xmpp:time'>"
+ "<tzo>-06:00</tzo>"
+ "<utc>2006-12-19T17:58:35Z</utc>"
+ "</time>"
+ "</iq>";
// @formatter:on
IQ iqResponse = (IQ) PacketParserUtils.parseStanza(response);
assertTrue(iqResponse instanceof Time);
Time time = (Time) iqResponse;
assertEquals("-06:00", time.getTzo());
assertEquals("2006-12-19T17:58:35Z", time.getUtc());
}
示例6: isTimeSupported
import org.jivesoftware.smackx.time.packet.Time; //導入依賴的package包/類
public boolean isTimeSupported(String jid) throws NoResponseException, XMPPErrorException, NotConnectedException {
return ServiceDiscoveryManager.getInstanceFor(connection()).supportsFeature(jid, Time.NAMESPACE);
}
示例7: TimeProvider
import org.jivesoftware.smackx.time.packet.Time; //導入依賴的package包/類
public TimeProvider() {
super(Time.class);
}