java - why local timeZone String is getting appended in the UTC date? -


i want date object in utc time zone converting first string returing me correct utc date string when again parsing date object local time zone string(ie. ist) getting appended in date instead of utc.

        date date = new date();         dateformat timeformat = new simpledateformat("mm/dd/yyyy hh:mm:ss");         timeformat.settimezone(timezone.gettimezone("utc"));         string esttime = timeformat.format(date);         date = new simpledateformat("mm/dd/yyyy hh:mm:ss", locale.english).parse(esttime); 

a date doesn't have timezone, represents moment in time. holds time in milliseconds.

you can't have date format, doesn't work way. if need show date in gui, console or anywhere else, that's when use simpledateformat did change string in format want.


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -