0

How to get the timezone from a date object of the system in java ? Like EST,PST,MST.

Apolo
  • 3,844
  • 1
  • 21
  • 51
Narendra M
  • 43
  • 1
  • 2
  • 4

2 Answers2

1

java.util.Date does not contain timezone information. You can check this post for some options.

Community
  • 1
  • 1
Predrag Maric
  • 23,938
  • 5
  • 52
  • 68
1

Java Date class can't get timezone directly.
You can see more details as below link.

http://stackoverflow.com/questions/1305350/how-to-get-the-current-date-and-time-of-your-timezone-in-java

Following is the way to get timezone using java.

Calendar calendar = new GregorianCalendar();
TimeZone timeZone = calendar.getTimeZone();

More details about timezone, here.

Ye Win
  • 2,020
  • 14
  • 21