Uploaded image for project: 'Pivot'
  1. Pivot
  2. PIVOT-577

Time.decode() throws NPE when no milliseconds present in input string

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.5
    • 2.0
    • core-util
    • None
    • JDK 6 Update 21

    Description

      Time.decode("12:34:56.789");
      works,

      Time.decode("12:34:56")
      throws a NullPointerException at org.apache.pivot.util.Time.decode(Time.java:399)

      I believe the problem is that matcher.groupCount() returns # of groups in pattern, not # of matched, so it always ==5; thus when no milliseconds passed, matcher.group(4) is null.

      if (matcher.groupCount() == 5)

      { millisecond = Integer.parseInt(matcher.group(4).substring(1)); }

      else

      { millisecond = 0; }

      Attachments

        Activity

          People

            gbrown Gregory K. Brown
            zorqie Ilian Pavlov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: