Here you can find the source of compareDateForSecond(Date src, Date target, int second)
public static boolean compareDateForSecond(Date src, Date target, int second)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static boolean compareDateForSecond(Date src, Date target, int second) { Calendar targetTime = Calendar.getInstance(); targetTime.setTime(target);/*from w ww. j av a2 s. c o m*/ targetTime.add(Calendar.SECOND, second); Calendar srcTime = Calendar.getInstance(); srcTime.setTime(src); return srcTime.compareTo(targetTime) <= 0; } }