Latest Time by Replacing Hidden Digits

给一个string, 表示时间, 里面有若干个?, 求把?替换成数字后的最大时间.

class Solution {
    public String maximumTime(String time) {
        String[] strs = time.split(":");
        String mins = strs[0];
        String secs = strs[1];
        if(mins.charAt(0) == '?'){
            if(mins.charAt(1) == '?'){
                mins = "23";
            }
            else{
                if('0' <= mins.charAt(1) && mins.charAt(1) <= '3'){
                    mins = "2" + mins.charAt(1);
                }
                else{
                    mins = "1" + mins.charAt(1);
                }
            }
        }else if(mins.charAt(0) == '0' || mins.charAt(0) == '1'){
            if(mins.charAt(1) == '?'){
                mins = mins.charAt(0) + "9";
            }
        } 
        else if(mins.charAt(0) == '2'){
            if(mins.charAt(1) == '?'){
                mins = "23";
            }
        }
        // secs
        if(secs.charAt(0) == '?'){
            if(secs.charAt(1) == '?'){
                secs = "59";
            }
            else{ 
                secs = "5" + secs.charAt(1); 
            }
        }
        else {
             if(secs.charAt(1) == '?'){
                secs = secs.charAt(0) + "9";
            }
        }
        return mins+":"+secs;
    }
}