I'm parsing a file and created a custom date format using the following code:
String s = tokens[0]+ " " + tokens[1];
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss.SSS");
try
{
Date date = simpleDateFormat.parse(s);
System.out.println("date : "+simpleDateFormat.format(date));
}
catch (ParseException ex)
{
System.out.println("Exception "+ex);
}
How do i work with dates from here after?
For example if i have two dates like this as per my output:
date : 2014-30-04 08:30:00.790
date : 2014-30-04 08:30:22.784
How do I calculate the time difference between them? I need minutes, seconds and milliseconds to be present in my output.