How to use TimeZone class of java
This tip will show the use of TimeZone class to get the time in different time zone.
Code:
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;
public class TimeZoneExp {
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("HHmmss");
TimeZone tz = TimeZone.getTimeZone("GMT");
Calendar day1 = Calendar.getInstance(tz);
sdf.setTimeZone(tz);
String resultTime = sdf.format(day1.getTime());
System.out.println(resultTime);
}
}