use of org.jivesoftware.smackx.time.packet.Time in project Smack by igniterealtime.
the class GeoLocationTest method negativeTimezoneTest.
@Test
public void negativeTimezoneTest() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT-830"));
Time time = new Time(calendar);
GeoLocation geoLocation = new GeoLocation.Builder().setTzo(time.getTzo()).build();
assertEquals("-8:30", geoLocation.getTzo());
}
use of org.jivesoftware.smackx.time.packet.Time in project Smack by igniterealtime.
the class EntityTimeManager method getTime.
public Time getTime(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
if (!isTimeSupported(jid))
return null;
Time request = new Time();
// TODO Add Time(Jid) constructor and use this constructor instead
request.setTo(jid);
Time response = (Time) connection().createStanzaCollectorAndSend(request).nextResultOrThrow();
return response;
}
use of org.jivesoftware.smackx.time.packet.Time in project Smack by igniterealtime.
the class TimeProviderTest method parseTimeWithIntrospectionTest.
@Test
public void parseTimeWithIntrospectionTest() throws Exception {
// @formatter:off
final String request = "<iq type='get'" + "from='romeo@montague.net/orchard'" + "to='juliet@capulet.com/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='juliet@capulet.com/balcony'" + "to='romeo@montague.net/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());
}
use of org.jivesoftware.smackx.time.packet.Time in project Smack by igniterealtime.
the class GeoLocationTest method positiveTimezonTest.
@Test
public void positiveTimezonTest() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT+530"));
Time time = new Time(calendar);
GeoLocation geoLocation = new GeoLocation.Builder().setTzo(time.getTzo()).build();
assertEquals("+5:30", geoLocation.getTzo());
}
Aggregations