Java Time Convert to timeToInt(final String time)

Here you can find the source of timeToInt(final String time)

Description

Parses time values such as 09:16:45 from gtfs to an integer values represented in seconds.

License

Open Source License

Parameter

Parameter Description
time the time to parse

Return

number of seconds for given time

Declaration

public static int timeToInt(final String time) 

Method Source Code

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

public class Main {
    /**/*from  w w w  .j a  v a2  s. com*/
     * Parses time values such as 09:16:45 from gtfs to an integer values 
     * represented in seconds. For example: 9*3600 + 16*60 + 45
     * 
     * @param time the time to parse
     * @return number of seconds for given time
     */
    public static int timeToInt(final String time) {

        String[] times = time.split(":");

        int hours = Integer.parseInt((String) times[0]);
        int minutes = Integer.parseInt((String) times[1]);
        int seconds = Integer.parseInt((String) times[2]);

        return (seconds + minutes * 60 + hours * 3600);
    }
}

Related

  1. timeToDriveDistanceDeadReckoning(double distance, double robotMaxSpeed, double targetSpeed)
  2. timeToExactString(double d)
  3. timeToFloat(String aTimeDuration)
  4. timeToFromNow(long time)
  5. timeToIndex(String twentyFourHourTime)
  6. timeToJgo(long milliSeconds)
  7. timeToLong(String inputStr)
  8. timeToMs(int day, int hour, int min, int sec)
  9. timeToRad(int time)