java - EST time conversion with daylight saving time -


est time conversion daylight saving time coming wrongly

private void timeconversion() {     string s = "2016-08-29 1:40:00 am";     dateformat df = new simpledateformat("yyyy-mm-dd hh:mm:ss a", locale.english);     df.settimezone(timezone.gettimezone("est"));     date timestamp = null;     try {         timestamp = df.parse(s);         df.settimezone(timezone.getdefault());         system.out.println(df.format(timestamp));     } catch (parseexception e) {         e.printstacktrace();      } } 

the time zone est not respect daylight saving time offsets:

timezone esttz = timezone.gettimezone("est"); system.out.println(esttz.usedaylighttime()); // prints 'false' 

that time zone est have -5:00 hour offset utc.

this due locations in canada, mexiko , central america (panama) not using dst using est year.

if want time zone dst offset, should use us/eastern or america/new_york, etc:

timezone useasterntz = timezone.gettimezone("us/eastern"); system.out.println(useasterntz.usedaylighttime()); // prints 'true' 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -