Search in sources :

Example 1 with Time

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());
}
Also used : Calendar(java.util.Calendar) Time(org.jivesoftware.smackx.time.packet.Time) XmppDateTime(org.jxmpp.util.XmppDateTime) Test(org.junit.Test)

Example 2 with Time

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;
}
Also used : Time(org.jivesoftware.smackx.time.packet.Time)

Example 3 with Time

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());
}
Also used : IQ(org.jivesoftware.smack.packet.IQ) Time(org.jivesoftware.smackx.time.packet.Time) Test(org.junit.Test)

Example 4 with Time

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());
}
Also used : Calendar(java.util.Calendar) Time(org.jivesoftware.smackx.time.packet.Time) XmppDateTime(org.jxmpp.util.XmppDateTime) Test(org.junit.Test)

Aggregations

Time (org.jivesoftware.smackx.time.packet.Time)4 Test (org.junit.Test)3 Calendar (java.util.Calendar)2 XmppDateTime (org.jxmpp.util.XmppDateTime)2 IQ (org.jivesoftware.smack.packet.IQ)1