src/share/classes/java/sql/Time.java

Print this page
rev 10459 : 8055055: Improve numeric parsing in java.sql

*** 98,113 **** if (s == null) throw new java.lang.IllegalArgumentException(); firstColon = s.indexOf(':'); secondColon = s.indexOf(':', firstColon+1); ! if ((firstColon > 0) & (secondColon > 0) & ! (secondColon < s.length()-1)) { ! hour = Integer.parseInt(s.substring(0, firstColon)); ! minute = ! Integer.parseInt(s.substring(firstColon+1, secondColon)); ! second = Integer.parseInt(s.substring(secondColon+1)); } else { throw new java.lang.IllegalArgumentException(); } return new Time(hour, minute, second); --- 98,112 ---- if (s == null) throw new java.lang.IllegalArgumentException(); firstColon = s.indexOf(':'); secondColon = s.indexOf(':', firstColon+1); ! if (firstColon > 0 && secondColon > 0 && ! secondColon < s.length() - 1) { ! hour = Integer.parseInt(s, 10, 0, firstColon); ! minute = Integer.parseInt(s, 10, firstColon + 1, secondColon); ! second = Integer.parseInt(s, 10, secondColon + 1); } else { throw new java.lang.IllegalArgumentException(); } return new Time(hour, minute, second);