1 20 21 package org.jivesoftware.smackx.packet; 22 23 import java.text.SimpleDateFormat ; 24 import java.util.Date ; 25 import java.util.TimeZone ; 26 27 import org.jivesoftware.smack.packet.PacketExtension; 28 29 39 public class DelayInformation implements PacketExtension { 40 41 public static SimpleDateFormat UTC_FORMAT = new SimpleDateFormat ("yyyyMMdd'T'HH:mm:ss"); 42 47 public static SimpleDateFormat NEW_UTC_FORMAT = 48 new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); 49 50 static { 51 UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0")); 52 NEW_UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC")); 53 } 54 55 private Date stamp; 56 private String from; 57 private String reason; 58 59 62 public DelayInformation(Date stamp) { 63 super(); 64 this.stamp = stamp; 65 } 66 67 74 public String getFrom() { 75 return from; 76 } 77 78 84 public void setFrom(String from) { 85 this.from = from; 86 } 87 88 94 public Date getStamp() { 95 return stamp; 96 } 97 98 104 public String getReason() { 105 return reason; 106 } 107 108 114 public void setReason(String reason) { 115 this.reason = reason; 116 } 117 118 public String getElementName() { 119 return "x"; 120 } 121 122 public String getNamespace() { 123 return "jabber:x:delay"; 124 } 125 126 public String toXML() { 127 StringBuffer buf = new StringBuffer (); 128 buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append( 129 "\""); 130 buf.append(" stamp=\"").append(UTC_FORMAT.format(stamp)).append("\""); 131 if (from != null && from.length() > 0) { 132 buf.append(" from=\"").append(from).append("\""); 133 } 134 buf.append(">"); 135 if (reason != null && reason.length() > 0) { 136 buf.append(reason); 137 } 138 buf.append("</").append(getElementName()).append(">"); 139 return buf.toString(); 140 } 141 142 } 143 | Popular Tags |