Here you can find the source of timeStringToSeconds(String str)
public static int timeStringToSeconds(String str) throws ParseException
//package com.java2s; /*// w ww . j a v a 2 s. c om * File: TimeHelper.java * Copyright (c) 2004-2007 Peter Kliem (Peter.Kliem@jaret.de) * A commercial license is available, see http://www.jaret.de. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html */ import java.text.ParseException; import java.util.StringTokenizer; public class Main { public static int timeStringToSeconds(String str) throws ParseException { try { StringTokenizer tokenizer = new StringTokenizer(str, ":"); int h = Integer.parseInt(tokenizer.nextToken()); int m = Integer.parseInt(tokenizer.nextToken()); int s = 0; if (tokenizer.hasMoreTokens()) { s = Integer.parseInt(tokenizer.nextToken()); } return h * 3600 + m * 60 + s; } catch (Exception e) { throw new ParseException(str, 0); } } }