Java: How to convert a string (HH:MM:SS) to a duration?
问题 i want to convert a string with a format of HH:MM:SS or MM:SS or SS into a datatype of Duration. solution: private ArrayList<Duration> myCdDuration = new ArrayList<Duration>(); private void convert(String aDuration) { chooseNewDuration(stringToInt(splitDuration(aDuration))); //stringToInt() returns an int[] and splitDuration() returns a String[] } private void chooseNewDuration(int[] array) { int elements = array.length; switch (elements) { case 1: myCdDuration.add(newDuration(true, 0, 0, 0,