Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calculating time and speed in Java GUI  RSS feed

 
Hank Harrison
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok here is my question. So i'm using Netbeans and have created this template for the program i want to create. Basically what I want to do is enter a time and date in 24hr format including seconds and the date of start and end time and have the program calculate the time difference between Tool launch and tool Receive that takes into factor the Launch and Receive Dates for a total of hh:mm:ss duration. I don't know how to combine both those factors output one number in a total number of hours Duration. I'm also having problems linking the ODO (odometer) which the formula would basically be time/ODO (or distance in feet) = x.x ft/sec format. Any clues or links that i should look into to help? Thanks a bunch.

 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hank Harrison wrote:Ok here is my question. So i'm using Netbeans and have created this template for the program i want to create. Basically what I want to do is enter a time and date in 24hr format including seconds and the date of start and end time and have the program calculate the time difference between Tool launch and tool Receive that takes into factor the Launch and Receive Dates for a total of hh:mm:ss duration. I don't know how to combine both those factors output one number in a total number of hours Duration. I'm also having problems linking the ODO (odometer) which the formula would basically be time/ODO (or distance in feet) = x.x ft/sec format. Any clues or links that i should look into to help? Thanks a bunch.


Stop the GUI coding and develop your program logic using classes that are independent of the way they receive input and provide output. Test those classes with a CLI (Command Line Interface), probably using Scanner and System.out. Once that's done, tying up the model to the GUI will be easy.

If you're using Java 8, there's a new Date/Time API which greatly simplifies the maths involved. (There's even a class named Duration)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!