I am trying to convert GMT timestamp to local timestamp with particular timezone
This is what I have implemented
public static void test(Timestamp p_gmtTime, String p_timeZone) throws ParseException {
SimpleDateFormat tzFormat = new SimpleDateFormat("MMM dd, yyyy HH:MM:SS a", Locale.ENGLISH);
tzFormat.setTimeZone(TimeZone.getTimeZone(p_timeZone)); // Use whatever timezone
tzFormat.format(p_gmtTime);
//System.out.println(tzFormat.format(p_gmtTime)); // This line gives correct o/p
Calendar calendar = tzFormat.getCalendar();
//calendar.setTime(tzFormat.parse(format));
System.out.println(calendar.getTime()); // this line gives wrong result
}
Issue comes when there is daylight savings are on, then it gives future date instead of current date,
lets say If I do transaction today 30-Dec-2021
it gives date of 31-Dec-2021
and I have limitation to use only calendar
object.
I need help in converting GMT Timestamp to local Timestamp with particular timezone