just for display:import java.util.*;
import java.text.*;public class Test{
public static void main(String[] args){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
sdf.setTimeZone(TimeZone.getTimeZone("Etc/Greenwich"));
System.out.println("The current time in Greenwich is: "+sdf.format(new Date()));
}
}
import java.text.*;public class Test{
public static void main(String[] args){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
sdf.setTimeZone(TimeZone.getTimeZone("Etc/Greenwich"));
System.out.println("The current time in Greenwich is: "+sdf.format(new Date()));
}
}
import java.text.*;
import java.util.GregorianCalendar.*;public class Test{
public static void main(String[] args){
TimeZone tz=TimeZone.getTimeZone("Etc/Greenwich"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
sdf.setTimeZone(tz);
System.out.println("The current time in Greenwich is: "+sdf.format(new Date()));
//using Calendar: Calendar calendar = new GregorianCalendar(tz);
Date date = new Date();
calendar.setTime(date); System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
System.out.println("MONTH: " + (calendar.get(Calendar.MONTH)+1));
System.out.println("DATE: " + calendar.get(Calendar.DATE));
System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
System.out.println("SECOND: " + calendar.get(Calendar.SECOND)); }
}