Oops. I noticed that Yahoo truncated part of my source because it was too long. Be sure you put your cursor over the code containing DateFormat to examine the rest of it! It's shown as a tooltip.
---
Hi, again, thanks for the note. As mentioned below (thanks), DATETIME isn't a standard Java class. Can you provide me an interface definition of it, or can you convert it to a standard Java Date object or can you convert it to a string? It's also possible to use the DateFormat class and specify a custom date type, but you will need to convert your DATETIME class objects all in to Strings.
--
Hi,
Using the Date class (java.util.Date), you can manipulate time, and using DateFormat, we can parse the time. Let's say that you have your date format as a String:
String timeIn;
String timeOut;
And now we want the difference of the time:
Date timeInD = DateFormat.getDateInstance().parse(timeIn);
Date timeOutD = DateFormat.getDateInstance().parse(timeOut);
long msec = timeOutD.getTime() - timeInD.getTime();
msec should now contain the time, in milliseconds, between your time-in and time-out.
To convert it to something useful:
float timeHours = msec / 1000 / 60 / 60;