Last active
March 11, 2020 19:20
-
-
Save theodesp/6eeba0152c1759203a037f8ab81d22a2 to your computer and use it in GitHub Desktop.
Date with Timezone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thdespou; | |
import java.util.Date; | |
import java.util.TimeZone; | |
public class Main { | |
public static void main(String[] args) { | |
// Date | |
Date now = new Date(); | |
System.out.println("Current Date in milliseconds is :" + now.getTime()); | |
// Display the instant in three different time zones | |
TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); | |
System.out.println(now); | |
TimeZone.setDefault( TimeZone.getTimeZone("GMT")); | |
System.out.println(now); | |
TimeZone.setDefault( TimeZone.getTimeZone("UTC")); | |
System.out.println(now); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment