java - How to add user timezone to utc date -


how add user timezone utc getting utc date

datetimeformatter formatter = datetimeformat.forpattern("yyyy-mm-ddhh:mm:ss"); datetime datetime = formatter.withoffsetparsed().parsedatetime(getval[2]); datetime datetimeutc = datetime.todatetime(datetimezone.utc); 

now want user timezone , add utc convert localtime

update

i able user timezone add utc

datetimeformatter formatter = datetimeformat.forpattern("yyyy-mm-ddhh:mm:ss"); datetime datetime = formatter.withoffsetparsed().parsedatetime(getval[2]);  java.util.calendar = java.util.calendar.getinstance(); java.util.timezone timezone = now.gettimezone();  datetimezone dtzone = datetimezone.forid(timezone.getid()); datetime datetimeutc = datetime.todatetime(datetimezone.utc); ofm.setdate(datetimeutc.todatetime(dtzone).todate()); 

this below code may time zone of user

//get calendar instance calendar = calendar.getinstance();  //get current timezone using gettimezone method of calendar class timezone timezone = now.gettimezone();  //display current timezone using getdisplayname() method of timezone class system.out.println("current timezone : " + timezone.getdisplayname()); 

also below link helps convert user's timezone utc

link


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -