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
Post a Comment