import java.util.Scanner;
public class Exercise5 {
public static void main(String[] Strings) {
Scanner input = new Scanner(System.in);
System.out.print("Input the time zone offset to GMT: ");
long timeZoneChange = input.nextInt();
long totalMilliseconds = System.currentTimeMillis();
long totalSeconds = totalMilliseconds / 1000;
long currentSecond = totalSeconds % 60;
long totalMinutes = totalSeconds / 60;
long currentMinute = totalMinutes % 60;
long totalHours = totalMinutes / 60;
long currentHour = ((totalHours + timeZoneChange) % 24);
System.out.println("Current time is " + currentHour + ":" + currentMinute + ":" + currentSecond);
}
}
Sample Output:
Input the time zone offset to GMT: 256
Current time is 5:7:51
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer