Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**
     * Takes a string of the form [HH:]MM:SS[.mmm] and converts it to
     * milliseconds.
     */
    public static long parseTimeString(final String time) {
        String[] parts = time.split(":");
        long result = 0;
        int idx = 0;
        if (parts.length == 3) {
            // string has hours
            result += Integer.valueOf(parts[idx]) * 3600000L;
            idx++;
        }
        result += Integer.valueOf(parts[idx]) * 60000L;
        idx++;
        result += (Float.valueOf(parts[idx])) * 1000L;
        return result;
    }
}