Search This Blog

Thursday, July 23, 2009

Java Time and UTC

Java does have a date type that is truly time zone ignorant: long. It is the time in milliseconds since January 1, 1970 UTC. It is the value you get when you say System.currentTimeMillis. You can convert that for display, to local time, server time, UTC, or any other time zone you want, when you want to display it. java.util.Date and java.sql.Date and java.sql.Time all wrap long, and they contain no time zone information at all. If you call toString(), it will format the time into a string using the local time zone, but toString() is intended primarily as a diagnostic tool. Most other methods on those classes are deprecated because date/time localization is not a trivial issue: they don't really work. java.util.Calendar is currently the preferred way to deal with date/time localization in Java. Use java.text.DateFormat for more flexible capabilities (it uses java.util.Calendar internally to do its work).

Friday, July 10, 2009

When Windows Explorer Acts Buggy

Recently, at work, my Windows XP machine started acting very strange: Windows Explorer took forever to list directories and appeared to be freezing up on occasion. When, after several re-boots the problem remained persistent I consulted with my Google friend.

The solution was relatively simple.

delete C:\Documents and Settings\\Local Settings\Application Data\Microsoft\Windows

(or you could simply rename it if you don't like the word delete)

However, there is one caveat: you need to sign in as a different user with local-admin rights in order to delete this file because you can't delete this file as the current user.

Hope this helps someone.