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
I need help ASAP 66 points this is a lab in Testout For Microsoft access I have been at this for about an hour
rosijanka [135]

Answer:

welp you have to umm look up Microsoft and you habe to reset the rask

7 0
2 years ago
Implement the function charCnt. charCnt is passed in a name of a file and a single character (type char). This function should o
SVEN [57.7K]

Answer:

Answered below

Explanation:

//Program is written in Python programming language

def charCnt( fileName, char){

if not fileName.exists( ):

return sys.exit(1)

else:

openFile = open("$fileName.txt", "r")

readFile = openFile.read( )

fileLength = len (readFile)

count = 0

for character in range(fileLength):

if readFile[character] == char:

count++

openFile.close( )

return count

}

7 0
2 years ago
In windows, a hamburger is an icon that, when clicked, displays a(n) _____________.
OleMash [197]
In windows, a hamburger is an icon that, when clicked, displays  three parallel horizontal lines. The hamburger button is a graphical shortcut placed typically in a top corner of the graphical user interface. It is used in small devices (smartphones for example) and the idea is to take less space. <span>The hamburger icon was originally designed by </span>Norm Cox<span> </span>
4 0
3 years ago
HTML5 is______because it works on tablet or smartphone,notebooks
jeyben [28]

Answer:

Wonderful and easy language

Explanation:

Hope this helps

3 0
3 years ago
Read 2 more answers
Use these sentence starters to explain how Cat Insanity is an analogy for debt repayment.
denpristay [2]

Answer: Can Insanity is like a debt repayment, if you don't pay or feed it on time they will die/ interest rate of the bank will be more and more expensive.

Explanation:

7 0
2 years ago
Other questions:
  • what is a massive online storage that allows for access by any Internet connected device running a web browser and is used for l
    7·1 answer
  • After clicking the Start button on your computer screen desktop, what option would you then select to examine system components
    10·2 answers
  • Consider the following partial class definitions: public class A1 { public int x; private int y; protected int z; ... } public c
    12·1 answer
  • What are youth oraganizations?
    7·1 answer
  • Drag the correct type of update to its definition.
    14·1 answer
  • According to the text, the three IT trends that are having the greatest impact on the IT environment are:
    11·1 answer
  • The local city youth league needs a database system to help track children that sign up to play soccer. Data needs to be kept on
    10·2 answers
  • Able to make a survey form using VB (Visual basics 6.0) to represent ways of conservation of
    8·2 answers
  • When backing up a database, what is added to the file name?<br> On g metrix
    9·1 answer
  • When using correct ergonomic technique be sure to _____.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!