• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Short/Long day?

 
Andrew Short
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a TimeZone:



The daylight savings start on the last Sunday in March at 0100 and finish on the last Sunday in October at 0100.

Given a java.util.Date, how do I find out whether this date is a Long or a Short day?

I suppose basically I am asking is how how do I implement this interface?

 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would use a Calendar - set it to the same date/time as the Date, then change the time to midnight on that day. Get a new Date to represent that date/time. Then add 1 to the date, so that the Calendar now represents midnight on the next day. Get another Date to represent that date/time. You can then find how much time difference there is between the two using getTime() to convert each Date to milliseconds. Compare this difference to 24 * 60 * 60 * 1000 to see if the difference is more or less than what you'd expect.
 
Andrew Short
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much, that works
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic