Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

Openfire 3.8.0 org.jivesoftware.util. XMPPDateTimeFormat.parseString

$
0
0

It may be a bug when initializing the two Matchers:

 

public synchronized Date parseString(String dateString) throws ParseException {

        // Jacky Jia 2013.02.20

        // should reverse the matchers

//        Matcher xep82WoMillisMatcher = xep80DateTimePattern.matcher(dateString);

//        Matcher xep82Matcher = xep80DateTimeWoMillisPattern.matcher(dateString);

        Matcher xep82WoMillisMatcher = xep80DateTimeWoMillisPattern.matcher(dateString);

        Matcher xep82Matcher = xep80DateTimePattern.matcher(dateString);

        // -----

 

        if (xep82WoMillisMatcher.matches() || xep82Matcher.matches()) {

            String rfc822Date;

            // Convert the ISO 8601 time zone string to a RFC822 compatible format

            // since SimpleDateFormat supports ISO8601 only with Java7 or higher

            if (dateString.charAt(dateString.length() - 1) == 'Z') {

                rfc822Date = dateString.replace("Z", "+0000");

            } else {

                // If the time zone wasn't specified with 'Z', then it's in

                // ISO8601 format (i.e. '(+|-)HH:mm')

                // RFC822 needs a similar format just without the colon (i.e.

                // '(+|-)HHmm)'), so remove it

                int lastColon = dateString.lastIndexOf(':');

                rfc822Date = dateString.substring(0, lastColon) + dateString.substring(lastColon + 1);

            }

 

            if (xep82WoMillisMatcher.matches()) {

                return dateTimeFormatWoMillies.parse(rfc822Date);

            } else {

                return dateTimeFormat.parse(rfc822Date);

            }

        } else {

            // at last try with the legacy format

            return dateTimeFormatOld.parse(dateString);

        }

    }


Viewing all articles
Browse latest Browse all 10742

Trending Articles