tags:

views:

42

answers:

0

Hi, All

I stumbled upon this piece of code to get current time in EST with daylight saving. It seems to work fine, when checked on the internet by the time displayed in sites providing current time in EST with daylight saving.

  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 anybody used something like this before or there is a better way to achieve the same. I cannot use Joda library due to constraints.

Thanks in advance.