Here you can find the source of getIntevalMinutes(String startDate, String endDate)
public static long getIntevalMinutes(String startDate, String endDate)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long getIntevalMinutes(String startDate, String endDate) { try {/* www. j ava 2s . c o m*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d1 = sdf.parse(startDate); Date d2 = sdf.parse(endDate); long minute = (d2.getTime() - d1.getTime()) / 1000 / 60; return minute; } catch (Exception ee) { System.out.println(ee); return 0; } } public static Date parse(String strDate, String pattern) throws ParseException { try { return getFormatter(pattern).parse(strDate); } catch (ParseException pe) { throw new ParseException("Method parse in Class DateUtil err: parse strDate fail.", pe.getErrorOffset()); } } private static SimpleDateFormat getFormatter(String parttern) { return new SimpleDateFormat(parttern); } }