// Yazzy Latif // 07/10/2020 // CSE142 // TA: Grace Hopper // To Days lecture example // This program computes how many days have elapsed since the epoch // (January 1st, 1970). /* DEVELOPMENT NOTES: ((Note: this is not something you should include in your own programs; this is included here to aid in your understanding and to provide additional context for the program.)) This was our introduction to returns and the Math class. Remember, there are three parts to a method that returns: - return statement - return type in the method header - catch/use the value where the method is called */ public class ReturnPractice { public static void main(String[] args) { long millis = System.currentTimeMillis(); double days = toDays(millis); int weeks = (int) days / 7; int extras = (int) days % 7; System.out.println("millis = " + millis); System.out.println("days = " + days); System.out.println("weeks = " + weeks); System.out.println("extras = " + extras); } // Calculates number of days that has passed since Jan 1, 1970 with given millis // double millis: millis to convert to days // Return: double representing the number of days that has elapsed public static double toDays(double millis) { double answer = millis / 1000.0 / 60.0 / 60.0 / 24.0; return answer; } }