java - Convert from string to UTC format -
i developing android app. in app working dates.
i need dates in utc format. using method convert them:
public date getconvertedutcdate(string datetime) { date mydate = null; simpledateformat dateformat = new simpledateformat("yyyy-mm-dd hh:mm:ss", locale.us); try { dateformat.settimezone(timezone.gettimezone("utc")); mydate = dateformat.parse(datetime); } catch (parseexception e) { e.printstacktrace(); } return mydate; } but instead of getting expected:
sun aug 10 14:13:14 utc 2014 i in cest format
sun aug 10 14:13:14 cest 2014 what doing wrong?
you set timezone calendar of parser. not timezone of parsed result.
Comments
Post a Comment