Re: Date Time additions/parsing



Carla wrote:
On Oct 31, 4:20 pm, Eric Sosman <Eric.Sos...@xxxxxxx> wrote:
Carla wrote:
Hi,
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?
Use the Calendar class.

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
.



Relevant Pages

  • Re: 3 value logic. Why is SQL so special?
    ... Flight entity is just equivalent to an assumed and recurring plane ... departure being associated to a specific departure airport. ... for some reason, AFAIAC, actual departure time can be safely deemed to ...
    (comp.databases.theory)
  • Re: Airport security procedures Europe->US?
    ... >> up 15 or 20 minutes before departure time and there will be ... > necessary to check-in 2-hrs before departure, ... I fly to the US many times each year, never been denied boarding yet. ... I doubt) where you'd be denied boarding for showing up at the gate 20 ...
    (rec.travel.air)
  • Re: In Case You Did Not Know***
    ... least 90 minutes prior to their ship's scheduled departure time and anyone ... for review at least 60 minutes prior to departure. ... full hours prior to the ship's scheduled departure time. ...
    (rec.travel.cruises)
  • Re: Date Time additions/parsing
    ... I have a GUI which has a departure date field, departure time ... to add the estimated time of journey to the departure date-time to ...
    (comp.lang.java.programmer)