Java Second Convert convertSeconds(String sStartSeconds, String sEndSeconds)

Here you can find the source of convertSeconds(String sStartSeconds, String sEndSeconds)

Description

Convert the seconds into format like: 00:00:08,200 --> 00:00:12,200

License

Open Source License

Parameter

Parameter Description
seconds a parameter

Declaration

public static String convertSeconds(String sStartSeconds, String sEndSeconds) 

Method Source Code

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

public class Main {
    /**/*from   www .j av  a 2 s  .  c  o  m*/
     * Convert the seconds into format like: 00:00:08,200 --> 00:00:12,200
     * 
     * @param seconds
     * @return
     */
    public static String convertSeconds(String sStartSeconds, String sEndSeconds) {
        double dStartSeconds = Double.parseDouble(sStartSeconds);
        double dEndSeconds = Double.parseDouble(sEndSeconds);

        return String.format("%s --> %s", innerConvert(dStartSeconds), innerConvert(dEndSeconds));
    }

    private static String innerConvert(double dSeconds) {
        int hours = (int) (dSeconds / 3600);
        int minutes = (int) ((dSeconds - 3600 * hours) / 60);
        int seconds = (int) (dSeconds % 60);
        int decimals = (int) ((dSeconds - (int) dSeconds) * 1000);

        return String.format("%02d:%02d:%02d,%03d", hours, minutes, seconds, decimals);
    }
}

Related

  1. convertDaysInMiliseconds(long lDays)
  2. convertMilisecondsRemainderToFrames(Integer miliseconds, int fps)
  3. convertMilisecondsToDisplay(Integer milliseconds, int fps)
  4. convertMsToFloatSeconds(final long timeMs)
  5. convertSecondsToDays(double secs)
  6. convertSecondsToMiliseconds(double seconds)
  7. convertSecondsToMiliseconds(int secondsToConvert)
  8. convertSecondsToMillies(final long seconds)