
package yahoofinance.quotes.stock;

import java.math.BigDecimal;
import java.util.Calendar;

/**
 * All getters can return null in case the data is not available from Yahoo Finance.
 * 
 * @author Stijn Strickx
 */
public class StockDividend {
    
    private final String symbol;
    
    private Calendar payDate;
    private Calendar exDate;
    private BigDecimal annualYield;
    private BigDecimal annualYieldPercent;
    
    public StockDividend(String symbol) {
        this.symbol = symbol;
    }
    
    public StockDividend(String symbol, Calendar payDate, Calendar exDate, BigDecimal annualYield, BigDecimal annualYieldPercent) {
        this(symbol);
        this.payDate = payDate;
        this.exDate = exDate;
        this.annualYield = annualYield;
        this.annualYieldPercent = annualYieldPercent;
    }

    public String getSymbol() {
        return symbol;
    }
    
    public Calendar getPayDate() {
        return payDate;
    }

    public void setPayDate(Calendar payDate) {
        this.payDate = payDate;
    }

    public Calendar getExDate() {
        return exDate;
    }

    public void setExDate(Calendar exDate) {
        this.exDate = exDate;
    }
    
    public BigDecimal getAnnualYield() {
        return annualYield;
    }
    
    public void setAnnualYield(BigDecimal annualYield) {
        this.annualYield = annualYield;
    }
    
    public BigDecimal getAnnualYieldPercent() {
        return annualYieldPercent;
    }
    
    public void setAnnualYieldPercent(BigDecimal annualYieldPercent) {
        this.annualYieldPercent = annualYieldPercent;
    }
    
    @Override
    public String toString() {
        String payDateStr = "/";
        String exDateStr = "/";
        if(this.payDate != null) {
            payDateStr = this.payDate.getTime().toString();
        }
        if(this.exDate != null) {
            exDateStr = this.exDate.getTime().toString();
        }
        return "Pay date: " + payDateStr + ", Ex date: " + exDateStr + ", Annual yield: " + this.getAnnualYieldPercent() + "%";
    }
    
}

@@ -1712,32 +1712,69 @@
 xDateStr = %22/%22;%0A
+        String annualYieldStr = %22/%22;%0A
         if(this.
@@ -1784,32 +1784,32 @@
 Date != null) %7B%0A
-
             payD
@@ -1956,32 +1956,159 @@
 ng();%0A        %7D%0A
+        if(this.annualYieldPercent != null) %7B%0A            annualYieldStr = this.annualYieldPercent.toString() + %22%25%22;%0A        %7D%0A
         return %22
@@ -2187,17 +2187,9 @@
 %22 + 
-this.getA
+a
 nnua
@@ -2194,25 +2194,19 @@
 ualYield
-Percent()
+Str
  + %22%25%22;%0A

Fix dividend print output