Here you can find the source of parseHHMMSSToSeconds(String txt)
public static double parseHHMMSSToSeconds(String txt) throws Exception
//package com.java2s; /*/* www . j a v a 2 s .co m*/ * Copyright (C) 2012-2015, Juan Manuel Barrios <http://juan.cl/> * All rights reserved. * * This file is part of P-VCD. http://p-vcd.org/ * P-VCD is made available under the terms of the BSD 2-Clause License. */ public class Main { public static double parseHHMMSSToSeconds(String txt) throws Exception { if (txt.length() == 0) return 0; String[] tim = txt.split(":"); if (tim.length == 1) return Double.parseDouble(tim[1]); else if (tim.length == 2) return Integer.parseInt(tim[0], 10) * 60 + Double.parseDouble(tim[1]); else if (tim.length == 3) return Integer.parseInt(tim[0], 10) * 3600 + Integer.parseInt(tim[1], 10) * 60 + Double.parseDouble(tim[2]); throw new Exception("invalid time format " + txt); } }