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
miskamm [114]
2 years ago
15

Write a program that estimates how many years, months, weeks, days, and hours have gone by since Jan 1 1970 by calculations with

the number of seconds that have passed.
Computers and Technology
1 answer:
Rzqust [24]2 years ago
6 0

Answer:

Explanation:

The following code is written in Java. It uses the LocalDate import to get the number of seconds since the epoch (Jan 1, 1970) and then uses the ChronoUnit import class to transform those seconds into years, months, weeks days, and hours. Finally, printing out each value separately to the console. The output of the code can be seen in the attached picture below.

import java.time.LocalDate;

import java.time.temporal.ChronoUnit;

class Brainly {

   public static void main(String[] args) {

       LocalDate now = LocalDate.now();

       LocalDate epoch = LocalDate.ofEpochDay(0);

       System.out.println("Time since Jan 1 1970");

       System.out.println("Years: " + ChronoUnit.YEARS.between(epoch, now));

       System.out.println("Months: " + ChronoUnit.MONTHS.between(epoch, now));

       System.out.println("Weeks: " + ChronoUnit.WEEKS.between(epoch, now));

       System.out.println("Days: " + ChronoUnit.DAYS.between(epoch, now));

       System.out.println("Hours: " + (ChronoUnit.DAYS.between(epoch, now) * 24));    

   }

}

You might be interested in
What will be the value of x after the following loop terminates?
Katena32 [7]

Answer:

10

Explanation:

This for-loop is simply iterating three times in which the value of x is being set to the value of x * 1.  So let's perform these iterations:

x = 10

When i = 0

x = x * 1 ==> 10

When i = 1

x = x * 1 ==> 10

When i = 2

x = x * 1 ==> 10

And then the for-loop terminates, leaving the value of x as 10.

Hence, the value of x is equal to 10.

Cheers.

7 0
3 years ago
What is the basic unit for storing data in exel
PtichkaEL [24]
A cell is the basic unit for storing data in exel
7 0
3 years ago
Should i change my profile pic<br> dont delete
nignag [31]
On the one hand it looks pretty cool, on the other hand change is good
8 0
3 years ago
Read 2 more answers
What was the importance of the turing machine to today’s computers?
Ronch [10]
It helps you with life and brainly
5 0
3 years ago
What is the best low end pc recording software​
julsineya [31]

Explanation:

democreator

D3DGear

nvidia shadow play etc

8 0
2 years ago
Read 2 more answers
Other questions:
  • James has been asked to build a low-profile computer for his friend to use as a home theater system. James needs to choose parts
    15·1 answer
  • PLEASE HURRY
    6·1 answer
  • Comparing tools made of stone, iron, and bronze: place them in the correct order from least to most durable
    14·1 answer
  • Consider the most important item among all the categories of information stored on your personal computer. As it applies to that
    8·1 answer
  • a(n) ___ loop allows you to cycle through an array without specifying the starting and ending points for the loop
    14·1 answer
  • What are the names of the 3 main languages used for making websites
    10·1 answer
  • If you use the assign software to a user option, how does the new software install to the user's computer? 70-411
    10·1 answer
  • Each student has a record on a file consisting of the following data: Student last name, Student ID (numeric), GPA (a decimal nu
    7·1 answer
  • Which of the following statement is correct ? A . potential difference is measured by ammeter . B . The unit of potential differ
    9·1 answer
  • 23. Convert the following to Megabytes<br> a) 2GB<br> b) 2056 Bytes-
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!