title: Java look up closest previous Date in HashMap
body: <p>I've got a problem to solve, where I need to create an accounting and bookkeeping solutions part in Java (just the backend, for now). They require the system to store previous prices of given products, so I decided to go with a <code>HashMap&lt;Date,Integer&gt;</code>. </p>
  
  <p>Now problem is, the system has to be able to retrieve prices in given times, for accounting, tracing back purchases (the order stores the item, and the purchase time, so it can be looked back easily). It would be all good, but if the purchase date does not match the price setting date, the simple get method returns null. And so far I haven't been able to logic out a search method what looks for the first previous date before the purchase date, to return the price.</p>
  
  <p>Is there any suggested way to solve this?</p>