import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the time zone offset to GMT: "); int offset = input.nextInt(); input.close(); 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 % 24; long currentHourWithOffset = currentHour + offset; if(currentHourWithOffset < 0) currentHourWithOffset += 24; else if(currentHourWithOffset > 23) currentHourWithOffset -= 24; System.out.println("The current time is " + currentHourWithOffset + ":" + currentMinute + ":" + currentSecond); } }