1

Possible Duplicate:
How to get the current date and time of your timezone in Java?

I have developed a Attendance System and in use for India. Our servers are in US and since they are using PDT. My code reflects time one hour ahead.

say its 9:00 am IST ---- I get the time as 10:00 am IST

other than detecting one hour from the time, which will be a temporary solution.

Pls suggest me some way to overcome this situation

Community
  • 1
  • 1
Meenakshi
  • 468
  • 3
  • 12
  • 31
  • It's not *at all* clear what you're doing here, partly because you haven't shown any code at all. Please give a short but complete example which demonstrates the problem, and read http://tinyurl.com/so-hints – Jon Skeet Jan 25 '12 at 10:38
  • This sounds like an [XY problem](http://mywiki.wooledge.org/XyProblem). – Jesper Jan 25 '12 at 10:46

1 Answers1

7

To check if a given Date is affected by daylight saving, use

Calendar c = Calendar.getInstance(timezone); // omit timezone for default tz
c.setTime(date); // your date; omit this line for current date
int offset = c.get(Calendar.DST_OFFSET);

0 means no DST, any other value (most likely 3600000) means that this date is affected by DST

Erich Kitzmueller
  • 36,381
  • 5
  • 80
  • 102