本文整理汇总了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);
}