Step 1:


Add the following comment block at the top of the file (cut and paste! don't retype the whole thing). Fill it in with your name (family names, given names), and your student number. Read the declaration.
/**
* Name: Last Name, First Name
*
* Student Number: xxxxxxxxx
*
* Declaration: I hereby assert that this application was written by me. I
* understand that it is a violation of the Senate Policy on Academic
* Honesty for me to submit someone else's work without identifying it as
* such and that this is a form of cheating. I also understand that if it is
* discovered that I have committed a breach of Academic Honesty for
* cheating or any other charge, then the full extent of available penalties
* may be brought against me.
*
*/




The class System has a service that has a service that will report the difference, measured in milliseconds, between the current time and midnight, January 1, 1970.
This method is static and its API is:
long currentTimeMillis()

This is the API - don't type this in your main method. Rather, the API tells you that the method called "
currentTimeMillis" returns a value that is of type long (long is like an int, but slightly different). Read the description of the method in Lab2.7 (p87 3ed, p91 3rd ed) (BUT DON'T DO WHAT THE LAB L2.7 SAYS - JUST READ THE BACKGROUND PART up to the paragraph that starts with "To measure a time interval....")

Declare a variable with the name
timeElapsedSince1970. It should be of type long.

Invoke the method. The method has no parameters.
Assign the value of the return of the method
currentTimeMillis to the variable timeElapsedSince1970.
Lab L2.7 has an example of invoking the method (although in that statement, the return is being assigned to a variable with the name
start).


Print out the value of the variable
timeElapsedSince1970 to the console.

  • To run Check02U, select Run -> Run As -> Java Application.
  • The output will appear in the console.
  • The green circle with the right triangle arrow in the menubar is the shortcut.

The output will look something like this (but the number will be larger).

Pasted Graphic 1