Hi,
I am trying to convert the time of my timezone to another time zone. Ans I have tried the following program and i got the exception. Kindly let me know if i am doing anything wrong.
import java.util.Calendar;
import java.util.GregorianCalendar;
public class GMTDateConversionTest {
public static void main(String[] args){
Calendar c = GregorianCalendar.getInstance();
c.setLenient(false);
c.set(2, 2);
c.set(5, 7);
c.set(1, 2009);
c.set(11,19);
c.set(12,0);
c.set(13, 0);
c.add(5, 1);
c.set(11, 2);
System.out.println(c.getTime()); // Exception occurs here when i try to print the c.gettime() ;
}
}
Exception in thread "main" java.lang.IllegalArgumentException: HOUR_OF_DAY
at java.util.GregorianCalendar.computeTime(Unknown Source)
at java.util.Calendar.updateTime(Unknown Source)
at java.util.Calendar.getTimeInMillis(Unknown Source)
at java.util.Calendar.getTime(Unknown Source)
at Use.GMTDateConversionTest.main(GMTDateConversionTest.java:34)
I am using Sun JDK 1.5.0_15
The issue occurs when my system time zone is "(GMT-07.00) Mountain Time (US & Canada)". The issue will not occurs when my time zone is "(GMT+05:30) Calcutta, Chennai, Mumbai, New Delhi"
Thanks In advance,
SelvaKumar S