• Post Reply Bookmark Topic Watch Topic
  • New Topic

printing the arrival and departure using datetime  RSS feed

 
orry kaplan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very close to finishing my program however I just need to print one last line and I am so confused as to why its not working! ive tried different ways and I keep getting errors with all sorts. This is my code.



I basically want it to print: "The flight between London and New York will take (7 hours and 30 minutes) however i need it to print it from the code above where i have the instant of arrival and departure. Any help???
 
Paul Clapham
Sheriff
Posts: 22509
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't it be sufficient to put that code right after line 56 of what you posted?
 
Knute Snortum
Sheriff
Posts: 4081
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use a Duration object and the getSeconds() method.
 
Paul Clapham
Sheriff
Posts: 22509
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "7 hours and 30 minutes" calculation is already hard-coded in the program, so I don't see a problem with hard-coding it in the printout as well. Like so:

 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duration has a static between method which calculates the time between two Temporal objects.
ZonedDateTime is a Temporal.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!