Java Second Convert convertTimecodeToSeconds(String timecode)

Here you can find the source of convertTimecodeToSeconds(String timecode)

Description

Converts the given timecode string of the form "HH:mm:ss[.SSS]" to the total number of seconds it represents

License

Open Source License

Parameter

Parameter Description
timecode a parameter

Return

the total number of seconds

Declaration

public static float convertTimecodeToSeconds(String timecode) 

Method Source Code

//package com.java2s;
/*//from w  w w.ja v a 2  s. c  om
 * Copyright (C) 2005-2014 Alfresco Software Limited.
 *
 * This file is part of Gytheio
 *
 * Gytheio is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gytheio is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Gytheio. If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Converts the given timecode string of the form "HH:mm:ss[.SSS]" to the
     * total number of seconds it represents
     * 
     * @param timecode
     * @return the total number of seconds
     */
    public static float convertTimecodeToSeconds(String timecode) {
        String[] timeParts = timecode.split(":");
        int hours = Integer.parseInt(timeParts[0]);
        int minutes = Integer.parseInt(timeParts[1]);
        float seconds = Float.parseFloat(timeParts[2]) + (60 * minutes) + (60 * 60 * hours);
        return seconds;
    }
}

Related

  1. convertSecondsToString(double seconds)
  2. convertSecondsToTime(int seconds)
  3. convertSecondsToTime(int totalSecs)
  4. convertSecondsToTimecode(float totalSeconds)
  5. convertSecondsToTimeUnits(int seconds)
  6. convertTimemilisecondsToHours(long time)
  7. convertTimeSecondsToHMS(long longSecs)
  8. convertTimeToSeconds(String a_time)
  9. convertToSeconds(String time)