aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/xmpp/time/TimePacketGenerator.java
blob: 344beb9e1adaa4e4702a371792d9803d9cf34477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package de.thedevstack.conversationsplus.xmpp.time;

import de.thedevstack.conversationsplus.xmpp.iqversion.IqVersionPacket;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;

/**
 * Generates the IQ Packets for Entity Time
 * as defined in XEP-0202.
 * @see <a href="http://xmpp.org/extensions/xep-0202.html">http://xmpp.org/extensions/xep-0202.html</a>
 */
public final class TimePacketGenerator {

    /**
     * Generates the IqPacket to reply the entity time.
     * <pre>
     * <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>
     * </pre>
     * @param packet
     * @return
     */
    public static TimePacket generateResponse(IqPacket packet) {
        TimePacket timePacket = new TimePacket();
        timePacket.setTo(packet.getFrom());
        timePacket.setId(packet.getId());

        return timePacket;
    }

    private TimePacketGenerator() {}
}