Here you can find the source of getIntervalMilSeconds(String startDateStr, String endDateStr, String dateFormat)
public static long getIntervalMilSeconds(String startDateStr, String endDateStr, String dateFormat) throws ParseException
//package com.java2s; /*// www. j a va 2s . co m * Copyright 1998-2012 360buy.com All right reserved. This software is the confidential and proprietary information of * 360buy.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only * in accordance with the terms of the license agreement you entered into with 360buy.com. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static long getIntervalMilSeconds(String startDateStr, String endDateStr, String dateFormat) throws ParseException { SimpleDateFormat format = new SimpleDateFormat(dateFormat); Date startDate = format.parse(startDateStr); Date endDate = format.parse(endDateStr); return endDate.getTime() - startDate.getTime(); } }