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
What is the computer's main memory, which consists of the random access memory (ram), cache memory, and read-only memory (rom) t
Nata [24]
Hey there!

The main memory of a computer that includes RAM, ROM, and cached information that is accessible through the CPU is called primary storage. These memory/storage types deal directly with how the computer functions and runs. The other type of storage is called secondary storage and refers to storage that isn't directly connected to the CPU, such as the hard drive. 

Hope this helped you out! :-)
5 0
3 years ago
The term "input file" is used to describe a file that data is written to.
worty [1.4K]
The answer to this question is true

4 0
3 years ago
The ______ sets rules for both the transport of data packets and the addressing system for a network such as the ARPANET
Phantasy [73]

The tool that sets rules for both the transport of data packets and the addressing system for a network such as the ARPANET is called; Protocol

<h3>Understanding Protocols</h3>

In computer systems communications, a protocol is defined as a set of rules and regulations that allow a network of nodes to transport and receive data information.

Now, each transport layer in a system of network such as ARAPNET will always have a protocol set such as TCP and IP.

Read more about internet protocols at; brainly.com/question/17820678

3 0
2 years ago
Importance of spread sheets​
Tema [17]

Answer:

It’s not that important but you can use it to help organize and grow your business.

Explanation:

3 0
3 years ago
People are more affected by technology than science because technology _____.
erik [133]
Has more of a direct influence in our everyday life because of the use of cellphones, technology, and cameras. Where else science is the idea that we should know affects us but often isn't clearly understood by the average person.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Several steps are involved in creating a presentation. what is the last step in the process before preparing to presenting it?
    12·1 answer
  • If a drastic change in environmental conditions results in a prolonged drought, how would the total population of ferns be affec
    14·2 answers
  • A user logging on, an application server connecting to a database server, an authentication server rejecting a password, or an a
    12·1 answer
  • ____, a Symantec product, offers a number of residential firewall and security applications that also provide various degrees of
    13·1 answer
  • Which of the following are provided by most
    5·1 answer
  • Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
    9·1 answer
  • Which shooting games is good for low end PC. CSGO or Valorant?​
    11·1 answer
  • How can a search be narrowed to only search a particular website????
    15·1 answer
  • Can anyone talk to me?
    9·2 answers
  • Match each task with the features necessary to complete the task
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!