Here you can find the source of getTimeDiff(String start, String end, String format, int timeDiff)
Parameter | Description |
---|---|
IOException | an exception |
public static long getTimeDiff(String start, String end, String format, int timeDiff) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**//ww w. j a v a 2 s.c o m * get time diff between start and end using format * @throws IOException */ public static long getTimeDiff(String start, String end, String format, int timeDiff) throws IOException { try { SimpleDateFormat dateFormat = new SimpleDateFormat(format); Date d1 = dateFormat.parse(start); Date d2 = dateFormat.parse(end); return ((d1.getTime() - d2.getTime()) / timeDiff); } catch (ParseException e) { throw new IOException("can't parse date, start:" + start + " end:" + end); } } }