java - Does Hibernate 4.x+ support Calendar objects whose time zones have been changed? -
i have been trying debug program while. , think may problem hibernates support calendar objects. example,
@entity @table(name="table") public class model { @id @generatedvalued(strategy=strategytype.identity) @column(name="id") private int id; //date_performed datetime type in sql server @column(name = "date_performed", nullable = false) @temporal(temporaltype.timestamp) private calendar dateperformed; //setters , getters omitted simplicity } class dao { @persistencecontext(...) private entitymanager entitymanager; public void savenewmodel(model m) { calendar c = m.getdateperformed(); system.out.println(c.get(calendar.hour_of_day)); //for example, suppose want save alaska time c.settimezone(timezone.gettimezone("us/alaska")); system.out.println(c.get(calendar.hour_of_day)); //<-- verification hour has gone 4 hours... yes has entitymanager.persist(m); } }
and problem is... in us/eastern time zone... 4 hours ahead of alaska time. when persist model saving eastern time (despite me changing time zone)... , if model gets saved between 12:00am , 4:00am, save incorrect day (because alaska time day before during hours) , things go bad program. best way around problem? how can save calendar object different timezone servers timezone? , either missing or accepted answer this question no longer case hibernate 4.x+
Comments
Post a Comment