Commit 9718a46e authored by Florian Schmaus's avatar Florian Schmaus Committed by flow

OF-646 The matches where accidentially interchanged. Added small testcase

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13541 b35dd754-fafc-0310-a699-88a17e54d16e
parent ddcff977
...@@ -96,8 +96,8 @@ public class XMPPDateTimeFormat { ...@@ -96,8 +96,8 @@ public class XMPPDateTimeFormat {
* @throws ParseException * @throws ParseException
*/ */
public Date parseString(String dateString) throws ParseException { public Date parseString(String dateString) throws ParseException {
Matcher xep82WoMillisMatcher = xep80DateTimePattern.matcher(dateString); Matcher xep82WoMillisMatcher = xep80DateTimeWoMillisPattern.matcher(dateString);
Matcher xep82Matcher = xep80DateTimeWoMillisPattern.matcher(dateString); Matcher xep82Matcher = xep80DateTimePattern.matcher(dateString);
if (xep82WoMillisMatcher.matches() || xep82Matcher.matches()) { if (xep82WoMillisMatcher.matches() || xep82Matcher.matches()) {
String rfc822Date; String rfc822Date;
......
package org.jivesoftware.util;
import static org.junit.Assert.assertEquals;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import org.junit.Test;
public class XMPPDateTimeFormatTest {
private final String TEST_DATE = "2013-01-25T18:07:22.768Z";
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
private final XMPPDateTimeFormat xmppDateTimeFormat = new XMPPDateTimeFormat();
@Test
public void failTest() {
Date parsedDate = null;
try {
parsedDate = xmppDateTimeFormat.parseString(TEST_DATE);
} catch (ParseException e) {
e.printStackTrace();
}
df.setTimeZone(TimeZone.getTimeZone("utc"));
String date = df.format(parsedDate);
assertEquals(date, "2013-01-25T18:07:22.768+0000");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment