Friday, October 30, 2009

Tech of the day: I hate time zone!

I have spent the past few hours on one issue: trying to insert a timestamp with time zone properly represented into Oracle through JDBC without success.

I started with using a DATE column in Oracle and a straighforward JdbcTemplate update method with Types.TIMESTAMP passed as the type. A timestamp like 2009-10-29 09:30 GMT+2 is stored as 2009-10-29 00:30, which is correct because my client and Oracle server both runs on PDT. Ideally I would rather store the timestamp in GMT, i.e., 2009-10-29 07:30. Alternatively, it would still be OK if I could store time zone into the database as well, i.e., using Oracle's TIMESTAMP WITH LOCAL TIME ZONE datatype (btw, I can't use TIMESTAMP WITH TIME ZONE if I want to use this column as the partition key!) Unfortunately, JdbcTemplate update for some reason stores it as 2009-10-28 05:30 PDT (i.e., it treated 2009-10-29 00:30 as a GMT time!)

It drove me crazy until I found this article from someone who has the same problem and provided a solution:
The resultSet.s[g]etTimeStamp method has an overloaded cousin, that takes a Calendar parameter.


To use this, you will also need to invoke a different cousin of JdbcTemplate's update which takes a PreparedStatementSetter and override the latter.

Thursday, October 29, 2009

Music of the day: RTHK2 Oldies

今日太太介紹聽香港電台第二台,我說這裡日間時段正是香港半夜,播的都是老餅歌,她說都可以聽啊。

於是我裝了iPhone App FStream,輸入了一堆URL,聽了:
關菊英-過客(無線同名電視劇主題曲)
葉振棠-勝利雙手創(亞洲電視劇「我來自潮州」主題曲,改編自紅極一時的台語歌「愛拼才會贏」)
張德蘭-愛的短箭(無線電視劇「家有嬌妻」主題曲)

的確好適合我這個老餅。

Wednesday, October 28, 2009

Topic of the day: Governator dropped The bomb

You have probably seen Arnold Schwarzenegger dropping bombs all the time in his action movies. This time he dropped the F-bomb, albeit a subtle one, in his message to legislators.

Interesting politics and politicians with guts? Yes! That's possible!