Conversion of UTC to IST time in java is working in LOCAL but not in CLOUD SERVER
Java Date
objects are already/always in UTC. Time Zone is something that is applied when formatting to text. A Date
cannot (should not!) be in any time zone other than UTC.
So, the entire concept of converting utcDate
to ISTDate
is flawed.
(BTW: Bad name. Java conventions says it should be istDate
)
Now, if you want the code to return the date as text in IST time zone, then you need to request that:
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);