Here you can find the source of getDateDifference(String start, String end)
public static double getDateDifference(String start, String end)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static double getDateDifference(String start, String end) { double result; DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); String start_fixed = start.substring(0, 23); // remove microseconds & timeoffset String end_fixed = end.substring(0, 23); // remove microseconds & timeoffset try {//w w w .j a v a 2s .c om Date startDate = format.parse(start_fixed); Date endDate = format.parse(end_fixed); result = endDate.getTime() - startDate.getTime(); result = result / 1000; } catch (ParseException pe) { result = -1; } return result; } }