Here you can find the source of timeDecimalSeconds(String time)
Parameter | Description |
---|---|
time | as "hours:minutes:seconds.decimal seconds" |
public static double timeDecimalSeconds(String time)
//package com.java2s; public class Main { /**/* w w w. j a v a 2 s . c o m*/ * Time converter. * @param time as "hours:minutes:seconds.decimal seconds" * @return decimal seconds */ public static double timeDecimalSeconds(String time) { return timeDecimal(time) * 3600; } /** * Time converter. * @param time as "hours:minutes:seconds.decimal seconds" * @return decimal hours */ public static double timeDecimal(String time) { String[] times = time.split(":"); if (times.length != 3) { return -9999; } double decimal = Double.parseDouble(times[0]); decimal += Double.parseDouble(times[1]) / 60.0; decimal += Double.parseDouble(times[2]) / 3600.0; return decimal; } }