Here you can find the source of timeToMinute(String time)
public static int timeToMinute(String time)
//package com.java2s; public class Main { public static int timeToMinute(String time) { // find split between hour and minute int mark = time.indexOf(':'); if (mark > 0) { // convert hour to adjusted range (0-11) int hour = Integer.parseInt(time.substring(0, mark)); if (hour == 12) { hour = 0;/*from ww w .j ava 2s . com*/ } // find minute value String mins = time.substring(mark + 1, time.length() - 1); int minute = Integer.parseInt(mins); // check am/pm flag char last = time.charAt(time.length() - 1); boolean pm = Character.toLowerCase(last) == 'p'; // return minute number of flight time return ((pm ? 12 : 0) + hour) * 60 + minute; } else { throw new IllegalArgumentException("Not a valid time: " + time); } } }