Getting historical stock quotes using yahoofinance API

Question:
How to get historical stock quotes using yahoofinance API?

Answer:
Here is an example on how to get historical stock quotes using the YahooFinance API.

Code:
import java.io.IOException;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import yahoofinance.Stock;
import yahoofinance.YahooFinance;
import yahoofinance.histquotes.HistoricalQuote;
import yahoofinance.histquotes.Interval;
 
public class YahooQuotes {
 
  public static void main(String[] args) throws IOException {
 
    Calendar from = new GregorianCalendar(2015, 5, 1);
    Calendar to = new GregorianCalendar(2015, 5, 10);
 
    Stock stock = YahooFinance.get("GOOG");
 
    List<HistoricalQuote> history = stock.getHistory(from, to, Interval.DAILY);
    for (HistoricalQuote hq : history) {
      System.out.print(hq.getSymbol() + " - ");
      System.out.print(hq.getClose() + " - ");
      System.out.println(hq.getDate().getTime());
    }    
 
  }
}

Output:
$ java YahooQuotes
GOOG - 536.690002 - Wed Jun 10 00:00:00 EDT 2015
GOOG - 526.690002 - Tue Jun 09 00:00:00 EDT 2015
GOOG - 526.830017 - Mon Jun 08 00:00:00 EDT 2015
GOOG - 533.330017 - Fri Jun 05 00:00:00 EDT 2015
GOOG - 536.700012 - Thu Jun 04 00:00:00 EDT 2015
GOOG - 540.309998 - Wed Jun 03 00:00:00 EDT 2015
GOOG - 539.179993 - Tue Jun 02 00:00:00 EDT 2015
GOOG - 533.98999 - Mon Jun 01 00:00:00 EDT 2015