Here you can find the source of parseTimeStringAsSeconds(String timeString)
static public int parseTimeStringAsSeconds(String timeString)
//package com.java2s; // This software is published under the terms of the MIT license, a copy public class Main { static public int parseTimeStringAsSeconds(String timeString) { int seconds; String[] timeComponents = timeString.split(":"); if (timeComponents.length == 0) { seconds = 0;//from www . j a v a 2s . co m } else if (timeComponents.length == 1) { seconds = Integer.parseInt(timeComponents[0]) * 60; } else if (timeComponents.length == 2) { int minutes = 0; if (!timeComponents[0].equals("")) { minutes = Integer.parseInt(timeComponents[0]); } seconds = Integer.parseInt(timeComponents[1]) + (60 * minutes); } else { seconds = 0; } return seconds; } }