mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 22:12:05 +01:00
SMACK-328 Added patches to fix threading issue with usage of SimpleDateFormatter.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_2_0@12030 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
75094d0199
commit
64d36a52e3
2 changed files with 17 additions and 16 deletions
|
@ -46,8 +46,9 @@ public class QueueDetails implements PacketExtension {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
||||
private static final String DATE_FORMAT = "yyyyMMdd'T'HH:mm:ss";
|
||||
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
/**
|
||||
* The list of users in the queue.
|
||||
*/
|
||||
|
@ -124,7 +125,7 @@ public class QueueDetails implements PacketExtension {
|
|||
|
||||
if (timestamp != null) {
|
||||
buf.append("<join-time>");
|
||||
buf.append(DATE_FORMATTER.format(timestamp));
|
||||
buf.append(dateFormat.format(timestamp));
|
||||
buf.append("</join-time>");
|
||||
}
|
||||
|
||||
|
@ -141,6 +142,8 @@ public class QueueDetails implements PacketExtension {
|
|||
public static class Provider implements PacketExtensionProvider {
|
||||
|
||||
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
QueueDetails queueDetails = new QueueDetails();
|
||||
|
||||
int eventType = parser.getEventType();
|
||||
|
@ -171,15 +174,13 @@ public class QueueDetails implements PacketExtension {
|
|||
time = Integer.parseInt(parser.nextText());
|
||||
}
|
||||
else if ("join-time".equals(parser.getName())) {
|
||||
joinTime = DATE_FORMATTER.parse(parser.nextText());
|
||||
joinTime = dateFormat.parse(parser.nextText());
|
||||
}
|
||||
else if( parser.getName().equals( "waitTime" ) ) {
|
||||
Date wait = DATE_FORMATTER.parse( parser.nextText() );
|
||||
Date wait = dateFormat.parse(parser.nextText());
|
||||
System.out.println( wait );
|
||||
}
|
||||
|
||||
|
||||
|
||||
eventType = parser.next();
|
||||
|
||||
if (eventType != XmlPullParser.END_TAG) {
|
||||
|
@ -187,8 +188,6 @@ public class QueueDetails implements PacketExtension {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
queueDetails.addUser(new QueueUser(uid, position, time, joinTime));
|
||||
|
||||
eventType = parser.next();
|
||||
|
|
|
@ -39,7 +39,8 @@ public class QueueOverview implements PacketExtension {
|
|||
*/
|
||||
public static String NAMESPACE = "http://jabber.org/protocol/workgroup";
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
||||
private static final String DATE_FORMAT = "yyyyMMdd'T'HH:mm:ss";
|
||||
private SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
private int averageWaitTime;
|
||||
private Date oldestEntry;
|
||||
|
@ -101,7 +102,7 @@ public class QueueOverview implements PacketExtension {
|
|||
buf.append("<count>").append(userCount).append("</count>");
|
||||
}
|
||||
if (oldestEntry != null) {
|
||||
buf.append("<oldest>").append(DATE_FORMATTER.format(oldestEntry)).append("</oldest>");
|
||||
buf.append("<oldest>").append(dateFormat.format(oldestEntry)).append("</oldest>");
|
||||
}
|
||||
if (averageWaitTime != -1) {
|
||||
buf.append("<time>").append(averageWaitTime).append("</time>");
|
||||
|
@ -119,6 +120,7 @@ public class QueueOverview implements PacketExtension {
|
|||
public PacketExtension parseExtension (XmlPullParser parser) throws Exception {
|
||||
int eventType = parser.getEventType();
|
||||
QueueOverview queueOverview = new QueueOverview();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
|
||||
|
||||
if (eventType != XmlPullParser.START_TAG) {
|
||||
// throw exception
|
||||
|
@ -135,7 +137,7 @@ public class QueueOverview implements PacketExtension {
|
|||
queueOverview.setAverageWaitTime(Integer.parseInt(parser.nextText()));
|
||||
}
|
||||
else if ("oldest".equals(parser.getName())) {
|
||||
queueOverview.setOldestEntry((DATE_FORMATTER.parse(parser.nextText())));
|
||||
queueOverview.setOldestEntry((dateFormat.parse(parser.nextText())));
|
||||
}
|
||||
else if ("status".equals(parser.getName())) {
|
||||
queueOverview.setStatus(WorkgroupQueue.Status.fromString(parser.nextText()));
|
||||
|
|
Loading…
Reference in a new issue