Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static long CompareTimeDelta(String arrivalTime) { Calendar calendarToday = Calendar.getInstance(); Calendar calendarTrainArrival = Calendar.getInstance(); long millisecondsCurrent = calendarToday.getTimeInMillis(); long millisecondsTrainArrival; int nowYear = calendarToday.get(Calendar.YEAR); int nowMonth = calendarToday.get(Calendar.MONTH); int nowDay = calendarToday.get(Calendar.DATE); int evalhr = 0; int evalmin = 0; int evalsec = 0; String delims = "[:]"; String[] timesplit = arrivalTime.split(delims); evalhr = Integer.parseInt(timesplit[0]); //HR evalmin = Integer.parseInt(timesplit[1]); //MIN evalsec = Integer.parseInt(timesplit[2]); //SEC - VRE does not provide a schedule down to seconds, so ignore. calendarTrainArrival.set(nowYear, nowMonth, nowDay, evalhr, evalmin); millisecondsTrainArrival = calendarTrainArrival.getTimeInMillis(); return millisecondsCurrent - millisecondsTrainArrival; } }