java - Convert W3C TimeZone to device TimeZone android -


what have

i have date string server in w3c date format 2016-02-13t09:53:49.871z

my problem

when post message server , shows 5 hrs before instead of now

what want

i wanted server timezone converted device timezone , irrespective of region , user see local time format

i solved , if 1 needs can refer code

public string convertw3ctodevicetimezone(string strdate) throws exception {         simpledateformat simpledateformatw3c = new simpledateformat("yyyy-mm-dd't'hh:mm:ss.sss'z'", locale.us);         simpledateformatw3c.settimezone(timezone.gettimezone("gmt"));         date dateserver = simpledateformatw3c.parse(strdate);          timezone devicetimezone = timezone.getdefault();         simpledateformat simpledateformat = new simpledateformat("yyyy-mm-dd hh:mm:ss");         simpledateformat.settimezone(devicetimezone);          string formatteddate = simpledateformat.format(dateserver);         return formatteddate;     } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -