Converting unix or java timestamps (time since the epoch) to real dates with Oracle

A few days ago I made use of a couple Oracle built in functions and it made me happy I didn’t have to write a stored proc or some type of mini-app to do it. I needed to parse a timestamp out of a field that was put there by a java program. The timestamp was just the output of System.currentTimeInMillis() and was concatenated onto some other information.

It took a little digging to find out how to convert a epoch style timestamp but here it is:

select new_time( to_date('01011970', 'ddmmyyyy') + 1/24/60/60 * :currenttimeinmillis/1000, 'GMT', 'EDT' ) from dual

Note that I convert the output from GMT to EDT here.

del.icio.us:Converting unix or java timestamps (time since the epoch) to real dates with Oracle digg:Converting unix or java timestamps (time since the epoch) to real dates with Oracle spurl:Converting unix or java timestamps (time since the epoch) to real dates with Oracle wists:Converting unix or java timestamps (time since the epoch) to real dates with Oracle simpy:Converting unix or java timestamps (time since the epoch) to real dates with Oracle newsvine:Converting unix or java timestamps (time since the epoch) to real dates with Oracle blinklist:Converting unix or java timestamps (time since the epoch) to real dates with Oracle furl:Converting unix or java timestamps (time since the epoch) to real dates with Oracle reddit:Converting unix or java timestamps (time since the epoch) to real dates with Oracle fark:Converting unix or java timestamps (time since the epoch) to real dates with Oracle blogmarks:Converting unix or java timestamps (time since the epoch) to real dates with Oracle Y!:Converting unix or java timestamps (time since the epoch) to real dates with Oracle smarking:Converting unix or java timestamps (time since the epoch) to real dates with Oracle magnolia:Converting unix or java timestamps (time since the epoch) to real dates with Oracle segnalo:Converting unix or java timestamps (time since the epoch) to real dates with Oracle gifttagging:Converting unix or java timestamps (time since the epoch) to real dates with Oracle

Leave a Reply