1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sleet_krkn [62]
2 years ago
15

Write a program in Java programming language that given two clock times prints out the absolute number of minutes between them

Computers and Technology
1 answer:
Triss [41]2 years ago
7 0

Answer:

// Java Program to Find the difference

// between Two Time Periods

// Importing the Date Class from the util package

import java.util.*;

// Importing the SimpleDateFormat

// Class from the text package

import java.text.*;

public class GFG {

public static void main(String[] args) throws Exception

{

 // Dates to be parsed

 String time1 = "18:00:00";

 String time2 = "7:30:50";

 // Creating a SimpleDateFormat object

 // to parse time in the format HH:MM:SS

 SimpleDateFormat simpleDateFormat

  = new SimpleDateFormat("HH:mm:ss");

 // Parsing the Time Period

 Date date1 = simpleDateFormat.parse(time1);

 Date date2 = simpleDateFormat.parse(time2);

 // Calculating the difference in milliseconds

 long differenceInMilliSeconds

  = Math.abs(date2.getTime() - date1.getTime());

 // Calculating the difference in Hours

 long differenceInHours

  = (differenceInMilliSeconds / (60 * 60 * 1000))

  % 24;

 // Calculating the difference in Minutes

 long differenceInMinutes

  = (differenceInMilliSeconds / (60 * 1000)) % 60;

 // Calculating the difference in Seconds

 long differenceInSeconds

  = (differenceInMilliSeconds / 1000) % 60;

 // Printing the answer

 System.out.println(

  "Difference is " + differenceInHours + " hours "

  + differenceInMinutes + " minutes "

  + differenceInSeconds + " Seconds. ");

}

}

You might be interested in
State the function of a URL in a website​
mihalych1998 [28]

Answer:

It's purpose is to access a webpage.

Explanation:

A URL contains detailed information on the webpage such as, the domain name, protocol, and path. This information directs the browser to the desired page.

3 0
3 years ago
Jamal is installing new software and would like a step-by-step guide to teach him how. Which resource would be best, and why?
ratelena [41]
The answer is D because it will explain and show how to install the software.
3 0
3 years ago
Read 2 more answers
Security is essential to keep in mind when doing business online. Select three tips for keeping customers' private
zlopas [31]
Make sure credit card processing uses a digital certificate to verify the processing site
5 0
3 years ago
Which technology is used to uniquely identify a wlan network?
expeople1 [14]
The answer is SSID

SSID which in full stands for Service Set Identifier is used to identify a network. It ensures that clients are able to locate a WLAN in which they are attached to. In Layman’s terms, it’s the username or the primary name in a WiFi setup in which a user joins and is connected to.






8 0
3 years ago
On which tab is the function library group located in excel
Neko [114]

The function library group is located in the "formulas" tab

7 0
4 years ago
Read 2 more answers
Other questions:
  • Can someone please give me a good definition to audience expectations!<br> (in film)
    8·1 answer
  • How does electricity work in phones?
    14·1 answer
  • An audit trail is a record of how a transaction was handled from input through processing and output
    10·1 answer
  • In an array based implementationof a queue a possible solution to dealing with the full condition is to
    14·1 answer
  • The key schedule results in generating multiple keys from the one secret key. These multiple keys are used:
    9·1 answer
  • Fill in the blank: _________ is Google’s machine-learning artificial intelligence system that interprets people’s searches to fi
    9·1 answer
  • Which componet is the smallest unit in a spreadsheet
    15·1 answer
  • Can somebody do an Algorithm 2 for more?<br> (Python)
    15·1 answer
  • Help! Picture provided
    7·2 answers
  • Which characteristics support an agile mis infrastructure?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!