How to Calculate Time Difference in Java?
Given two strings of time, you may want to calculate the difference between them. The following provide a simple solution.
Note that the different is in milliseconds, it needs to be divided by 1000 to get the number of seconds. You can easily change the parameter of SimpleDateFormat to use other format of time. For example,"HH:mm:ss.SSS" will also take the milliseconds. For more information about SimpleDateFormat, go to its Java Doc.