title: Getting the Time component of a Java Date or Calendar
body: <p>Is there a simple or elegant way to grab only the time of day (hours/minutes/seconds/milliseconds) part of a Java Date (or Calendar, it really doesn't matter to me)? I'm looking for a nice way to separately consider the date (year/month/day) and the time-of-day  parts, but as far as I can tell, I'm stuck with accessing each field separately.</p>
  
  <p>I know I could write my own method to individually grab the fields I'm interested, but I'd be doing it as a static utility method, which is ugly. Also, I know that Date and Calendar objects have millisecond precision, but I don't see a way to access the milliseconds component in either case.</p>
  
  <hr>
  
  <p><strong>Edit:</strong> I wasn't clear about this: using one of the Date::getTime() or Calendar::getTimeInMillis is not terribly useful to me, since those return the number of milliseconds since the epoch (represented by that Date or Calendar), which does not actually separate the <em>time of day</em> from the rest of the information.</p>
  
  <p>@Jherico's answer is the closest thing, I think, but definitely is something I'd still have to roll into a method I write myself. It's not exactly what I'm going for, since it still includes hours, minutes, and seconds in the returned millisecond value - though I could probably make it work for my purposes.</p>
  
  <p>I still think of each component as <em>separate</em>, although of course, they're not. You can write a time as the number of milliseconds since an arbitrary reference date, or you could write the exact same time as <code>year/month/day hours:minutes:seconds.milliseconds</code>.</p>
  
  <p>This is not for display purposes. I know how to use a <code>DateFormat</code> to make pretty date strings.</p>
  
  <hr>
  
  <p><strong>Edit 2:</strong> My original question arose from a small set of utility functions I found myself writing - for instance:</p>
  
  <ul>
  <li>Checking whether two <code>Date</code>s represent a date-time on the same day;</li>
  <li>Checking whether a date is within a range specified by two other dates, but sometimes checking inclusively, and sometimes not, depending on the time component.</li>
  </ul>
  
  <p>Does Joda Time have this type of functionality?</p>
  
  <hr>
  
  <p><strong>Edit 3:</strong> @Jon's question regarding my second requirement, just to clarify: The second requirement is a result of using my Dates to sometimes represent entire days - where the time component doesn't matter at all - and sometimes represent a date-time (which is, IMO, the most accurate word for something that contains <code>year/month/day</code> <em>and</em> <code>hours:minutes:seconds:...</code>).</p>
  
  <p>When a Date represents an entire day, its time parts are zero (e.g. the Date's "time component" is midnight) but the semantics dictate that the range check is done inclusively on the end date. Because I just leave this check up to Date::before and Date::after, I have to add 1 day to the end date - hence the special-casing for when the time-of-day component of a Date is zero.</p>
  
  <p>Hope that didn't make things less clear.</p>