Question: Java has a method that will give you the current time. You can call it by first typing this in to the REPL: import static

Java has a method that will give you the current time. You can call it by first typing this in to the REPL:

import static java.lang.System.currentTimeMillis;

Afterward, get the current time by calling:

currentTimeMillis()

The only problem... it gives you the current time as the number of milliseconds since midnight UTC (Links to an external site.)Links to an external site., January first, 1970! Note that it also gives it to you as a long integer (because this number is too large to fit in to a normal integer).

Develop a compound expression that includes a call to this function and evaluates to the current hour. Experiment with JShell to get it right (note that the hour should match the clock on your computer if you have the expression right).

Once you've developed an expression that you believe works correctly, submit it in the textbox below.

Another note: This method may or may not account for leap seconds that have taken place since 1970 depending on the operating system Java is running on (documented here (Links to an external site.)Links to an external site.). Do not worry about accounting for this in your expression.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!