Calculate Date/Time Difference in Java considering AM/PM
问题 I want to calculate the difference between two date/time in java using Date and Calendar classes. The format that I have is "2012-01-24 12:30:00 PM". I have implemented my own method and also google it to work with others, but haven't getting the right hint to handle AM and PM values. The date/time difference got troubled whenever the time have 12(AM/PM) in it. For example if I have date/time "2012-01-24 12:30:00 PM" and "2012-01-24 02:30:00 PM" it shows the difference is 10 hours.