Here you can find the source of getTimeSeconds(Calendar cal)
Parameter | Description |
---|---|
cal | the Calendar representing the time |
public static int getTimeSeconds(Calendar cal)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { /**//from w w w .j a va2 s.c o m * Get the number of seconds (in the day) for the specified time * in hours and minutes. This returns 0 for 12:00 AM, 3600 * for 1:00 AM, etc. * @param hour the 24 hour representation of the hours (can be 24+) * @param min the number of minutes in the hour * @return the number of seconds in the day */ public static int getTimeSeconds(int hour, int min) { return (hour * 3600) + (min * 60); } /** * Wrapper for getTimeSeconds(int hour, int min). * * Get the number of seconds (in the day) for the specified time, * represented by the Calendar. This returns 0 for 12:00 AM, 3600 * for 1:00 AM, etc * @param cal the Calendar representing the time * @return the number of seconds in the day */ public static int getTimeSeconds(Calendar cal) { return getTimeSeconds(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE)); } /** * Wrapper for getTimeSeconds(int hour, int min). * * Get the number of seconds (in the day) for the specified time, * represented by a GTFS 24+ hour time string. This returns 0 for * 12:00 AM, 3600 for 1:00 AM, etc * @param gtfsTime HH:mm:ss time representation (HH can be > 24) * @return the number of seconds in the day */ public static int getTimeSeconds(String gtfsTime) { String[] parts = gtfsTime.split(":"); int hour = Integer.parseInt(parts[0]); int min = Integer.parseInt(parts[1]); return getTimeSeconds(hour, min); } }