Is there an API with which I could obtain the exchange rate of bitcoin to dollar some time in the past by giving the desired time as parameter? I would also like the the result to be precise to hour (or minute).

It is for a java program.

I have looked around, but the service I have found could not satisfy my need:
http://www.coindesk.com/api/: only precise to date

https://api.coinbase.com/v1/prices/historical?page=1 (from https://community.coinbase.com/t/past-bitcoin-exchange-rates/1725): need to adjust page number to find the desired time (at which one wants the value of exchange rate)

http://api.bitcoincharts.com/v1/csv/: I am not exactly sure what it does, but it seems that one needs to download different files from this site containing "USD" in the file names, check in all the files before finding the desired time
You can use winkdex.com api, it accepts a unix timestamp as a parameter.
http://docs.winkdex.com/#price