Reputation: 1143
Today in Us day Light Saving has been started which is PST from today.
I have Day length as 24 hours which makes the calculation wrong for today. I see issue in the following code which is used for day comparison.
Upvotes: 2
Views: 50
Reputation: 52770
A simple trick would be something like this:
Calendar c = Calendar.getInstance();
c.setTime(new Date());
int h = c.get(Calendar.HOUR);
final int DAY = 24 * 60 * 60000;
Date temp = new Date(endDate1.getTime() + DAY);
c.setTime(temp);
int dh = c.get(Calendar.HOUR);
if(dh != h) {
// moving between daylight saving time
if(dh > h) {
// out of daylight saving
} else {
// into daylight saving
}
}
Upvotes: 1