Java Date objects are already / always in UTC. The time zone is what applies when formatting text. A Date cannot (should not!) Be in any time zone except UTC.
Thus, the whole concept of converting utcDate to ISTDate is erroneous.
(BTW: Bad name. Java conventions say it should be ISTDate )
Now, if you want the code to return the date as text in the IST time zone, you need to request the following:
DateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); formatter.setTimeZone(TimeZone.getTimeZone("Asia/Kolkata")); // Or whatever IST is supposed to be return formatter.format(utcDate);
source share