In this section, you will learn to convert a GMT to IST format. The GMT stands for Greenwich Mean Time and IST stands for India Standard Time.
Convert GMT to IST
In this section, you will learn to convert a GMT to IST format. The GMT stands for Greenwich Mean
Time and IST stands for India Standard Time.
Description of program:
This example helps you in converting a GMT time to IST time on the console. The SimpleDateFormat()
constructor uses the given pattern and date format symbols. Here we use the date format
as gmtFormat which gets converted to istFormat. Then we have used
getTimeZone() method to get the time of both the zones to be converted.
India Standard Time is 5.5 hours (5 hours 30 minutes) ahead of Greenwich Mean Time (GMT+5.5).
Here is the code of program:
|
Output of the program:
C:\unique>javac GMTtoIST.java C:\unique>java GMTtoIST GMT Time: 8/4/07 9:49 AM IST Time: 8/4/07 3:19 PM C:\unique> |