Discuss / Java / 交作业

交作业

Topic source

public static int[] parseTime(String s) {

if (s != null) {

Pattern p = Pattern.compile("([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])");

Matcher m = p.matcher(s);

if (m.matches()) {

return new int[] {Integer.valueOf(m.group(1)),Integer.valueOf(m.group(2)),Integer.valueOf(m.group(3))};

}

}

throw new IllegalArgumentException();

}


  • 1

Reply