How can I display the current time as GMT?
Created Oct 30, 2001
Joe Sam Shirah Create a custom TimeZone and use it for DateFormat.setTimeZone(). This is discussed briefly in the API documentation and shown in the following code.
import java.text.*;
import java.util.*;
public class GMTFmt2
{
public static void main( String[] args )
{
TimeZone tz = TimeZone.getTimeZone("GMT:00");
DateFormat dfGMT = DateFormat.getTimeInstance( DateFormat.LONG );
dfGMT.setTimeZone( tz );
System.out.println( dfGMT.format( new Date() ) );
} // end main
} // End class GMTFmt2