protected static final Long parseUsingFallbacksWithColon(String text, DateTimeFormat timeFormat) {
        if (text.indexOf(':') == -1) {
            text = text.replace(" ", "");
            int numdigits = 0;
            int lastdigit = 0;
            for (int i = 0; i < text.length(); i++) {
                char c = text.charAt(i);
                if (Character.isDigit(c)) {
                    numdigits++;
                    lastdigit = i;
                }
            }
            if (numdigits == 1 || numdigits == 2) {
                // insert :00
                int colon = lastdigit + 1;
                text = text.substring(0, colon) + ":00" + text.substring(colon);
            }
            else if (numdigits > 2) {
                // insert :
                int colon = lastdigit - 1;
                text = text.substring(0, colon) + ":" + text.substring(colon);
            }
            return parseUsingFallbacks(text, timeFormat);
        }
        else {
            return null;
        }
    }
protected static final Long parseUsingFallbacksWithColon ( String text , DateTimeFormat timeFormat ) { if ( text . indexOf ( ':' ) == - 1 ) { text = text . replace ( " " , "" ) ; int numdigits = 0 ; int lastdigit = 0 ; for ( int i = 0 ; i < text . length ( ) ; i ++ ) { char c = text . charAt ( i ) ; if ( Character . isDigit ( c ) ) { numdigits ++ ; lastdigit = i ; } } if ( numdigits == 1 || numdigits == 2 ) { int colon = lastdigit + 1 ; text = text . substring ( 0 , colon ) + ":00" + text . substring ( colon ) ; } else if ( numdigits > 2 ) { int colon = lastdigit - 1 ; text = text . substring ( 0 , colon ) + ":" + text . substring ( colon ) ; } return parseUsingFallbacks ( text , timeFormat ) ; } else { return null ; } }
Attempts to insert a colon so that a value without a colon can
be parsed.