Clan x86

Technical (Development, Security, etc.) => General Programming => Tutorials, References, and Examples => Topic started by: Camel on November 01, 2007, 03:37:46 pm

Title: [Java] Converting Windows FileTimes to java.lang.Dates
Post by: Camel on November 01, 2007, 03:37:46 pm
If you live in a DST observing timezone, these numbers will be one hour off this week. This appears to be a bug with Java not respecting the new DST rules.

Funny how we'll throw an entire week in to chaos to avoid two hours of confusion during a time when normal people are asleep.

Code: [Select]
/**
* Converts a Windows FileTime structure to a Date
* @param ft contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
* @return a Date with the correct time
*/
public static Date fileTime(long ft) {
// Date.parse("1/1/1601") == 11644455600000L
long date = ft / 10000 - 11644455600000L;
date += TimeZone.getDefault().getOffset(date);
return new Date(date);
}
Title: Re: [Java] Converting Windows FileTimes to java.lang.Dates
Post by: Chavo on November 01, 2007, 05:03:30 pm
DST is retarded anyway :/  The primary cause for it's use to begin with isn't even necessary anymore.
Title: Re: [Java] Converting Windows FileTimes to java.lang.Dates
Post by: iago on November 01, 2007, 06:36:58 pm
DST is retarded anyway :/  The primary cause for it's use to begin with isn't even necessary anymore.
You mean to encourage people to shop for an extra hour during the summer? 

Or is that just the conspiracy theory? :)
Title: Re: [Java] Converting Windows FileTimes to java.lang.Dates
Post by: Skywing on November 01, 2007, 08:30:32 pm
DST is retarded anyway :/  The primary cause for it's use to begin with isn't even necessary anymore.

I'm not all that enthusiastic about DST either, but the reasons for it are certainly still relevant today with continually rising energy prices (http://www.cbsnews.com/stories/2007/11/01/business/main3439639.shtml).
Title: Re: [Java] Converting Windows FileTimes to java.lang.Dates
Post by: Chavo on November 01, 2007, 10:26:37 pm
I'm not all that enthusiastic about DST either, but the reasons for it are certainly still relevant today with continually rising energy prices (http://www.cbsnews.com/stories/2007/11/01/business/main3439639.shtml).
Energy savings were shown in multiple cases to be negligible or just plain not there.

http://www.env-econ.net/2007/03/are_daylight_sa.html
http://www.ucei.berkeley.edu/PDF/csemwp163.pdf

Quote
You mean to encourage people to shop for an extra hour during the summer?
No, to give farmers an extra hour of daylight to match up with the economy's trading hours.