Here you can find the source of convertTimeToDurationMilliseconds(String time)
Parameter | Description |
---|---|
time | the time |
public static long convertTimeToDurationMilliseconds(String time)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w .j a v a2 s . c o m * Convert a time string in format HH:MM:SS in a milliseconds duration. * * @param time * the time * @return */ public static long convertTimeToDurationMilliseconds(String time) { long retObj = 0; if (time != null) { try { Integer hours = Integer.valueOf(time.substring(0, 2)); Integer minutes = Integer.valueOf(time.substring(3, 5)); Integer seconds = Integer.valueOf(time.substring(6, 8)); retObj += hours * 60 * 60 * 1000; retObj += minutes * 60 * 1000; retObj += seconds * 1000; } catch (NumberFormatException e) { } } return retObj; } }