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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -