I can get the time as well as the timezone currently, but it is always printed in
Wed May 23 11:01:08 GMT+05:30 2012
As TimeZone I am getting GMT+05:30. instead of this, I want to print IST
I tried
SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z");
but still, I am getting GMT+05:30
TimeZone.getDefault().getDisplayName(true, TimeZone.SHORT); is also givine me GMT+05:30
There are various things I tried but did not get the desired output. I have used Calender but still unable to print IST.
Can anyone please let me know how to print IST in Time (even I don’t want to print Indian standard time)
You haven’t shown where you’re actually using the
SimpleDateFormat. Here’s a short but complete example which does show IST:Output on my machine:
Note that if
TimeZone.getDefault()isn’t showing “IST” then the issue may be:Which version of Java are you using, and on what platform?