This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Short/Long day? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Short/Long day?" Watch "Short/Long day?" New topic
Author

Short/Long day?

Andrew Short
Greenhorn

Joined: Feb 13, 2008
Posts: 2
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

Joined: Mar 05, 2008
Posts: 3013
    
  10
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

Joined: Feb 13, 2008
Posts: 2
Thanks very much, that works
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Short/Long day?