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
Which of the following is the best reason for including a photograph in a formal business document
Bond [772]

Answer:

The answer is "The reader wants to see how your product looks".

Explanation:

Some information is missing in the question. so, the correct choice can be described as follows:

  • The corporation uses records and reports to transfer facts, statistics, and figures, including explanations for enhancing activities, administration, and sales.  
  • It generally refers to the various documentation, all with various sections and contents.  
  • In the organization's usage of records for correspondence, transaction, and product research, that's why the "reader wants to see how your product looks" is the correct choice.
8 0
4 years ago
Once we have reached complete efficiency in the third part of the LRAS Curve, what occurs?
sergiy2304 [10]

your answer is c hope this helps


8 0
4 years ago
In what country did true printing first take place?
kow [346]
Germany. Johannes Guten in Mainz, Germany
7 0
3 years ago
Read 2 more answers
What is the output of the following JavaScript code?
Kazeer [188]

Answer:

<h2>Arrow function expression var arrowMultiplyBy2 = num => num * 2; If the function takes in only one argument, then the parenthesis around the parameter can be omitted as shown in the code above. ... Code 1 - Output in the following order: undefined 42. </h2>

Explanation:

7 0
3 years ago
Maria is developing an online gaming website. She is working on an interactive game that has a central character guiding visitor
hammer [34]

Answer:

The answer is animation. This question has been answered already.

Source:

brainly.com/question/12414395

8 0
2 years ago
Other questions:
  • When a typist changes from a conventional typewriter to a word processor, his typing schema will have to _____ to incorporate th
    12·1 answer
  • Which vpn protocol is a poor choice for high-performance networks with many hosts due to vulnerabilities in ms-chap?
    15·1 answer
  • What allows user to double click with the mouse in a document to move the insertion point to a new location.?
    8·1 answer
  • This project involves writing a program that encodes and decodes messages. The program should prompt the user to select whether
    15·1 answer
  • What is a new technology in computer science that is emerging to solve a social, economic, or technological problem.
    9·1 answer
  • Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
    14·1 answer
  • The term "exception propagation" means:
    5·1 answer
  • Hahaahhaahahuahaahahhahqha
    13·1 answer
  • WAp to input the radius and print<br> the area of circle
    15·1 answer
  • joe is in the planning stages to make sure that an upcoming company promotion during a major sporting event will not overwhelm h
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!