Java tutorial
//package com.java2s; public class Main { public static String getTwoHour(String st1, String st2) { String[] kk = null; String[] jj = null; kk = st1.split(":"); jj = st2.split(":"); if (Integer.parseInt(kk[0]) < Integer.parseInt(jj[0])) return "0"; else { double y = Double.parseDouble(kk[0]) + Double.parseDouble(kk[1]) / 60; double u = Double.parseDouble(jj[0]) + Double.parseDouble(jj[1]) / 60; if ((y - u) > 0) return y - u + ""; else return "0"; } } }