Here you can find the source of substract(Time thisDeparture, Time firstDeparture)
public static Time substract(Time thisDeparture, Time firstDeparture)
//package com.java2s; //License from project: Open Source License import java.sql.Time; import java.util.Calendar; import java.util.TimeZone; public class Main { public static Time substract(Time thisDeparture, Time firstDeparture) { Calendar firstCal = Calendar.getInstance(TimeZone.getDefault()); firstCal.setTime(firstDeparture); Calendar secondCal = Calendar.getInstance(TimeZone.getDefault()); secondCal.setTime(thisDeparture); secondCal.add(Calendar.HOUR_OF_DAY, 0 - firstCal.get(Calendar.HOUR_OF_DAY)); secondCal.add(Calendar.MINUTE, 0 - firstCal.get(Calendar.MINUTE)); secondCal.add(Calendar.SECOND, 0 - firstCal.get(Calendar.SECOND)); return new Time(secondCal.getTime().getTime()); }/*from w w w .j a v a2 s . c o m*/ }