Here you can find the source of getSecondsFromStringDuration(String duration)
public static long getSecondsFromStringDuration(String duration)
//package com.java2s; public class Main { public static long getSecondsFromStringDuration(String duration) { long result = 0; String[] tokens = duration.split("[:\\.]"); int hours = Integer.parseInt(tokens[0]); int minutes = Integer.parseInt(tokens[1]); int seconds = Integer.parseInt(tokens[2]); int tenthMillis = Integer.parseInt(tokens[3]); result += hours * 3600;/*from w w w .j a v a2 s .com*/ result += minutes * 60; result += seconds; if (tenthMillis > 50) { result++; } return result; } }