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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -