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:
[code lang=”sql”]select new_time( to_date(‘01011970’, ‘ddmmyyyy’) + 1/24/60/60 * :currenttimeinmillis/1000, ‘GMT’, ‘EDT’ ) from dual[/code]
Note that I convert the output from GMT to EDT here.
[tags]java, oracle[/tags]