Here you can find the source of DateTimeSpace(String starttime, String endtime)
public static long DateTimeSpace(String starttime, String endtime)
//package com.java2s; import java.text.*; public class Main { public static long DateTimeSpace(String starttime, String endtime) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); long starttimes = 0; long endtimes = 0; long spacetime = 0; try {/* ww w .ja v a 2 s . c om*/ starttimes = sdf.parse(starttime).getTime(); endtimes = sdf.parse(endtime).getTime(); } catch (ParseException e) { System.out.println(e); } spacetime = Math.abs(endtimes - starttimes) / 1000 / 60; return spacetime; } public String getTime() { java.sql.Time ent = new java.sql.Time(System.currentTimeMillis()); return ent.toString(); } }