Monthly Archives: April 2006

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.

Tags: ,

Thread pooling with Java concurrency utilities new (java 1.5) and old (util.concurrent)

Threading in java is fairly easy and now with java 1.5 some of the stuff that was harder has become even easier. A few years ago someone pointed me to a site that had some concurrency utils that where the precursor to what are now the concurrent utils in java 1.5. They are very close in functionality and if you can't use java 1.5 the older version of the utils will work with older versions of java and give you a lot of the same functionality.

I'm going to give a quick thread pooling example using both the new and old concurrency utils. I picked the thread pooling out of both since that seems to be what I end up using the most out of all the new utilities. I may revisit this again at some point to go over the periodic executors or some of the other things I have used but just not as much.

Continue reading

Approximating a circle with a polygon

I recently had an opportunity to use ESRI's ArcSDE again. It is a spatial database interface and in this instance I was using the java api. I wanted to change what used to be a query using a rectangle into a query using a circle. For some reason parts of the java api for ArcSDE require a C library or something. I gave up pretty quickly on trying to make their arc function work since the documentation wasn't very clear on how it worked. Instead I decided to figure out how to approximate a circle with a polygon and use that instead. Here is the result of that research.

Continue reading

AJAX file upload progress for Java using commons fileupload and prototype

This has been done before with PHP (AJAX upload progress meter for PHP) etc but I needed something a little different because I wanted to upload a file and then have it loaded into a database. I looked around and found that someone had already made something that used the commons file upload package to do the upload part (AJAX Upload progress monitor for Commons-FileUpload Example). It wasn't exactly what I was looking for but it a good start.

Continue reading