My DB is running in ET time. My java application server is running in PT timezone.
Application code --- entitybean.setdate(Util.converCurrentDateToTimeZoneDate("ET"));
public static Date converCurrentDateToTimeZoneDate(String timeZone){
Calendar calInput = new GregorianCalendar();
Calendar calOutput = new GregorianCalendar();
if (timeZone.equals("ET")){
calInput.setTimeZone(TimeZone.getTimeZone("America/New_York"));
}
if (timeZone.equals("PT")){
calInput.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
}
if (timeZone.equals("CT")){
calInput.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
}
if (timeZone.equals("MT")){
calInput.setTimeZone(TimeZone.getTimeZone("America/Denver"));
}
calOutput.setTimeZone(calInput.getTimeZone());
return calOutput.getTime();
}
The scenario is :
If my server time is 1:00 PM PT time, the util is converting it to 4:00PM ET correctly, which is the value which i want to store in table.
But when I save the entity the value that is getting reflected in table is 4:00 PM PT.
Please help in resolving this issue ?