Changing timezone to IST

I am programmatically trying to set the timezone to Indian Standard Time (IST) in Android, but nothing seems to work!

Here's the code snippet:

SimpleDateFormat s = new SimpleDateFormat("HH:mm:ss");
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Kolkata"));
//  TimeZone.setDefault(TimeZone.getTimeZone("GMT +5:30"));
//  TimeZOne.setDefault(TimeZone.getTimeZone("IST"));
Calendar c = Calendar.getInstance();
System.out.println(s.format(c.getTime()));
Jon Skeet
people
quotationmark

Rather than changing the default time zone (which you're doing after creating the SimpleDateFormat) you should just set the time zone of the SimpleDateFormat:

SimpleDateFormat s = new SimpleDateFormat("HH:mm:ss");
s.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata"));
System.out.println(s.format(new Date()));

people

See more on this question at Stackoverflow