Skip to content

Instantly share code, notes, and snippets.

@theodesp
Last active Mar 11, 2020
Embed
What would you like to do?
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