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
Post a Comment