0

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.

Jason Fox
  • 5,115
  • 1
  • 15
  • 34
P_Ser
  • 1
  • 2
  • possible duplicate of [Calculate date/time difference in java](http://stackoverflow.com/questions/5351483/calculate-date-time-difference-in-java) – Basil Bourque Sep 25 '14 at 19:11
  • Welcome to StackOverflow. A couple tips: Make the title of your question describe the key issue. Your last two sentences could have been fashioned into a better title. Also, please search StackOverflow before posting. This topic has been addressed hundreds of times. – Basil Bourque Sep 25 '14 at 19:15

0 Answers0