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
Explain what mistake Miranda made in the following scenario. Situation: Miranda suspects that there may be a problem with the ha
Dennis_Churaev [7]

Answer: Answer below.

Explanation:

I'm not fully sure myself, so don't agree with me fully.

I believe what she may have done wrong is tell the technician about a "program." A program doesn't have to do anything with physical hardware.

5 0
3 years ago
Read 2 more answers
PLZ ANSWER WORTH 20 POINTS!! URGENT!
omeli [17]

Answer:

C. a registered Microsoft Account

8 0
2 years ago
Read 2 more answers
Proponents of Internet freedom see its _____________ as providing protection for unpopular expression; proponents of greater Int
NeTakaya

Answer: The answer is anonymity

Explanation: i had the same question on my test.

8 0
2 years ago
Computer __ is any part of the computer that can be seen and touched​
iogann1982 [59]
Hardware
Answer. physical parts of computer which can be seen and touched are called Hardware.
3 0
2 years ago
The __________ endian storage format places the __________ byte of a word in the lowest memory address. The __________ endian st
mr Goodwill [35]

Answer:

i. Big

ii. most significant

iii. little

iv. most significant

Explanation:

8 0
2 years ago
Other questions:
  • In which career field would the computing technology industry associations compTIA A+ certification be useful
    6·1 answer
  • Which one of the following characteristics or skills of a ScrumMaster are closelyaligned with coaching?Select one:
    5·1 answer
  • The blank contains the computer's brain the central processing unit CPU
    8·1 answer
  • What type of things can be marketed
    11·1 answer
  • A trust domain is defined as Select one: a. The agreed upon, trusted third party b. A scenario where one user needs to validate
    5·2 answers
  • Write a line of code to convert time to hours. Remember there are 60 minutes in an hour. Then write a line of code to calculate
    9·2 answers
  • Create a function names minElement() that takes an array of numbers as a paaramter and returns the min value of the array. The a
    9·1 answer
  • What happens when a string doesn’t include the separator that’s specified in the parameter of the split() method?
    13·1 answer
  • Create a method called randomValues that uses a while loop to generate a random number between 1-25 until the value 10 is genera
    12·1 answer
  • jelaskan tiga kemungkinan sebab pengasah pensil itu tidak dapat berfungsi secara tiba-tiba (translate: explain three possible re
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!