Re: Date Time additions/parsing
- From: Eric Sosman <Eric.Sosman@xxxxxxx>
- Date: Fri, 31 Oct 2008 17:03:48 -0400
Carla wrote:
On Oct 31, 4:20 pm, Eric Sosman <Eric.Sos...@xxxxxxx> wrote:Carla wrote:Hi,Use the Calendar class.
I have a GUI which has a departure date field (text), departure time
field (text), and once the user enters information about these, I have
to add the estimated time of journey to the departure date-time to
calculate arrival date-time.
Can someone help me, please?
Can you give me a short example to start with? for date-arithmatic I
mean.
// Inputs:
Date depart = ...;
int journeyHours = ...;
int journeyMonutes = ...;
// Computation:
Calendar cal = Calendar.getInstance();
cal.setTime(depart);
cal.add(Calendar.MINUTE, journeyHours * 60 + journeyMinutes);
// Optional adjustment:
if (destination == Airport.CHICAGO_OHARE)
cal.add(Calendar.MINUTE, 2 * 60 + 30); // congestion
// Output:
Date arrive = cal.getTime();
--
Eric.Sosman@xxxxxxx
.
- References:
- Date Time additions/parsing
- From: Carla
- Re: Date Time additions/parsing
- From: Eric Sosman
- Re: Date Time additions/parsing
- From: Carla
- Date Time additions/parsing
- Prev by Date: Re: kosher jpgs
- Next by Date: Re: 7.0 wishlist?
- Previous by thread: Re: Date Time additions/parsing
- Index(es):
Relevant Pages
|