java - How to store timestamp in mysql based on Timezone? -
i want store timestamp last_login in login table. creating time in dao layer , updating in table when user logs in. problem is, want update based on timezone. code is
simpledateformat formatter = new simpledateformat("dd-mm-yyyy hh:mm:ss"); final timezone utc = timezone.gettimezone("ist"); formatter.settimezone(utc); calendar c = calendar.getinstance(); c.add(calendar.date, 0); // number of days add string date = (string) (formatter.format(c.gettime())); date converteddate = formatter.parse(date); date timestampobj = new timestamp(converteddate.gettime());
this returning me timestamp of server. if server in uk, timestamp of uk. know mysql timestamp stores time in utc. rather saving time in ist, saving time in uk. how shall proceed?
from gather, need verify server time.
check operating systems time set ist (utc offset: utc +5:30).
Comments
Post a Comment