I am getting same time for EST and CST.Please find the code below.
Calendar.getInstance(TimeZone.getTimeZone("EST")); and
Calendar.getInstance(TimeZone.getTimeZone("CST")); both returns the same time.
Please help me to resolve this issue.
The reason you get the same time is because EST returns Standard time while CST the Daylight time.
Date today = new Date(); DateFormat df = new SimpleDateFormat("HH:mm:SS z"); df.setTimeZone(TimeZone.getTimeZone("US/Eastern")); String time = df.format(today); System.out.println(time); df.setTimeZone(TimeZone.getTimeZone("EST")); time = df.format(today); System.out.println(time); df.setTimeZone(TimeZone.getTimeZone("CST")); time = df.format(today); System.out.println(time);
and this is the output:
04:55:839 EDT 03:55:839 EST 03:55:839 CDT
EST time is not the correct time because it is actually 04:55 there right now, so US/Eastern will give you the correct (EDT) time. As a rule of thumb, I would recommend always using the US/Eastern and US/Central formats for safety.
answered Dec 19 '25 11:12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With