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
Dwight <br> d. eisenhower was impressed with germany's network of highways and how it __________.
emmasim [6.3K]
Eased the mobilization and transportation of troops
5 0
3 years ago
You visit two websites about inventions of the 21st century. One has .edu in the URL address and the other has .com. Which site
Kobotan [32]
Since you are searching for researching information, .edu will be more reliable.

.edu is for education purpose, with credits of scholars.

.com is a general URL, it's not relavant to reliability.
4 0
3 years ago
Read 2 more answers
An advertisement for new headphones lists the cool colors available, the great sound quality, and the fabulous reviews but fails
Mama L [17]

d transfer

ive seen the ad

7 0
3 years ago
To maintain your body temperature, your body converts chemical potential energy into thermal energy T or F
PilotLPTM [1.2K]
True
This is physics btw
CPE --> TE
4 0
3 years ago
In a __________, you are trying to find what others have prepared. With __________, you are trying to discover new patterns that
AveGali [126]

Answer:

<u>query,</u> <u>data mining </u>

Explanation:

A query can be explained as another term for question.

If one needs additional information from some other person, he might have ask to him. Queries are used for the retrieval of the information.

In other words, one tries to find what have been prepared by others.

Data mining can be explained as the process that allows to sort through a large set of data for the identification of patterns.

In this process of data mining, one tries to find out the new patterns that may not be known at all.

3 0
3 years ago
Other questions:
  • What is the difference between deta security and privecy ?
    12·2 answers
  • A Game Object must have a Transform<br><br> True<br><br> False
    5·1 answer
  • Which of the following Google tools support collaboration? Docs Sheets Slides All of the Above
    13·1 answer
  • How do u use this app?
    15·2 answers
  • Which of the following can a cell contain?
    9·2 answers
  • What is the model for 2017 Ford Mustang v6
    15·1 answer
  • Create a macro named mReadInt that reads a 16- or 32-bit signed integer from standard input and returns the value in an argument
    5·1 answer
  • A group of users in a small publishing office want to share large image files in a common folder with high availability. Which o
    15·1 answer
  • Question 1(Multiple Choice Worth 5 points)
    9·2 answers
  • Due TODAY!!! Can someone please help me!!!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!