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

How to get a single StockQuote using yahoofinance API?

Question:
How to get a StockQuote using yahoofinance API?

Answer:
Here is a simple example on how to get a single quote using the Java Finance Quotes API for Yahoo.Finance

Code:
import java.io.IOException;
import yahoofinance.Stock;
import yahoofinance.YahooFinance;
import yahoofinance.quotes.stock.StockQuote;
 
public class YahooStockQuoteAPI {
 
  public static void main(String[] args) throws IOException {
    YahooFinance yahoo = new YahooFinance();
    Stock stock = yahoo.get("GOOG");
    StockQuote sq = stock.getQuote();
 
    System.out.println("Symbol: " + sq.getSymbol());
    System.out.println("Price: " + sq.getPrice());
    System.out.println("Date: " + sq.getLastTradeTime().getTime());
  }
}

Output:
$ java YahooStockQuoteAPI 
Symbol: GOOG
Price: 662.20
Date: Fri Oct 16 16:00:00 EDT 2015