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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -