Convert GMT+ date to local on android -


i need convert date mon nov 14 13:36:01 gmt+03:00 2016 local. must 16:36:01

date serverdate; // mon nov 14 13:36:01 gmt+03:00 2016  simpledateformat dateformat = new simpledateformat("hh:mm:ss"); string result = dateformat.formatdate(serverdate); 

result doesn't see gmt +03:00 , gives me wrong time (13:36 instead of 16:36).

so needed create formatter without zzzzz , set time zone gmt.

    simpledateformat simpledateformat = new simpledateformat("yyyy-mm-dd't'hh:mm:ss", locale.getdefault());     simpledateformat.settimezone(timezone.gettimezone("gmt"));     final date localdate = simpledateformat.parse("2016-11-11t09:48:24-05:00");      simpledateformat dateformat = new simpledateformat("hh:mm:ss");     string result = dateformat.formatdate(localdate); //12:48:24 

after code time of localdate variable 12:48:24 (in case of gmt +03:00).


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -