Skip to content

Instantly share code, notes, and snippets.

@theodesp
Last active March 11, 2020 19:20
Show Gist options
  • Save theodesp/6eeba0152c1759203a037f8ab81d22a2 to your computer and use it in GitHub Desktop.
Save theodesp/6eeba0152c1759203a037f8ab81d22a2 to your computer and use it in GitHub Desktop.
Date with Timezone
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