In this java Program we are using SimpleDateFormat class to display a date in multiple Timezone in Java.
Java program to display a date in different timezone in Java
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class Main
{
public static void main(String args[]) {
//capturing current date
Date current_date = new Date();
//Below Code displaying date on BST timezone
DateFormat date_format = new SimpleDateFormat("dd-MM-yy HH:mm:SS z");
TimeZone time_zone = TimeZone.getTimeZone("Europe/London");
date_format.setTimeZone(time_zone);
String BST = date_format.format(current_date);
System.out.println("Date in BST Timezone : " + BST);
//Below Code dispalying date on EDT timezone
date_format.setTimeZone(TimeZone.getTimeZone("America/New_York"));
String EDT = date_format.format(current_date);
System.out.println("Date in EDT Timezone : " + EDT);
//Below Code dispalying date on IST timezone
date_format.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata"));
String IST = date_format.format(current_date);
System.out.println("Date in Indian Timezone (IST) : " + IST);
}
}
After execution of above code you will get the output like below:-
