I stumbled upon this piece of code to get the current time in EST with daylight saving time. It seems to work fine when it is checked on the Internet by the time displayed on sites providing current time in EST with daylight saving time.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss.SSS"); dateFormat.setTimeZone(TimeZone.getTimeZone("EST5EDT")); System.out.println(dateFormat.format(new Date()));
I just want to confirm, has anyone used something like this before, or is there a better way to achieve the same. I cannot use the Joda library due to limitations.
Thanks in advance.
java date time
baba.kabira
source share