I have got a date in this format: 2015-07-29 16:29:32
How can I check the difference in minutes between the current date and the given date?
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test {
public static void main(String[] args) throws ParseException {
String datetocomparestr = "2015-07-29 16:29:32";
SimpleDateFormat datetocomparesdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
Date d1 = null;
d1 = datetocomparesdf.parse(datetocomparestr);
System.out.println(d1);
SimpleDateFormat dateFormatcurrentsdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
Date date = new Date();
System.out.println(dateFormatcurrentsdf.format(date));
}
}
Could you please let me know how to resolve this. Thanks in advance.