Possible Duplicates:
Calculating difference in dates in Java
How can I calculate a time span in Java and format the output?
Say you were given two dates as strings and they are in this format 8/11/11 9:16:36 PM how would I go about converting them to java Date objects so that I can then calculate the difference between two dates?
As long as both times are in GMT/UTC, you can do
date1.getTime() - date2.getTime()and then divide the result by 86400000 to get number of days. The rest is probably pretty intuitive.EDIT — based on edited question
To convert Strings into dates, use the SimpleDateFormat class.