You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Sandro Martini (JIRA)" <ji...@apache.org> on 2010/07/22 15:58:53 UTC

[jira] Commented: (PIVOT-577) Time.decode() throws NPE when no milliseconds present in input string

    [ https://issues.apache.org/jira/browse/PIVOT-577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12891161#action_12891161 ] 

Sandro Martini commented on PIVOT-577:
--------------------------------------

Hi Greg,
> Hope you don't mind that I took this issue
don't worry, I'm not jealous :-)

Bye


> Time.decode() throws NPE when no milliseconds present in input string
> ---------------------------------------------------------------------
>
>                 Key: PIVOT-577
>                 URL: https://issues.apache.org/jira/browse/PIVOT-577
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-util
>    Affects Versions: 1.5
>         Environment: JDK 6 Update 21
>            Reporter: Ilian Pavlov
>            Assignee: Greg Brown
>            Priority: Minor
>             Fix For: 2.0
>
>
> 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;
>         }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.