0

i want to create a java program that displays the current time in GMT timezone using System.currentTimeMillis() method.

public class DisplayTime {
    public static void main(String[] args){

        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 = totalMinutes % 12;
        System.out.println(currentHour + " : " + currentMinute + " : " + currentSecond);
    }
}
Developer Limit
  • 155
  • 1
  • 3
  • 9

1 Answers1

0

I think this was answered on this post:How to transform currentTimeMillis to a readable date format? [duplicate]

Community
  • 1
  • 1
funcoding
  • 741
  • 6
  • 11