Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    private static final String COLON = ":";

    public static int formatDurationString(String durationString) {
        int duration = 0;
        if (durationString == null || durationString.length() == 0) {
            return duration;
        }

        try {
            String sArray[] = durationString.split(COLON);
            double hour = Double.valueOf(sArray[0]);
            double minute = Double.valueOf(sArray[1]);
            double second = Double.valueOf(sArray[2]);

            return (int) (((hour * 60 + minute) * 60 + second) * 1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return duration;
    }
}