Java Entity Hibernate to Oracle Timezone conversion issue -
my db running in et time. java application server 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 :
if server time 1:00 pm pt time, util converting 4:00pm et correctly, value want store in table.
but when save entity value getting reflected in table 4:00 pm pt.
please in resolving issue ?
i'm not sure got point hope comment experience in finding correct answer. assuming using oracle date type, best of knowledge, doesn't have timezone information in (as java date, stores time difference in ms). deal timezones when display or represent date.
if keep in mind can ignore timezones on db side of application , focus on java client; example if can consider dates in pt timezone, store them dates on database, , represent them timezone need when have diplay them.
please consider link further reading issue:
how store date/time , timestamps in utc time zone jpa , hibernate
hope helps.
Comments
Post a Comment