*/
// FIXME: this method is potentially harmful in heavily multi-threaded environments
public Date date(final String immCode, final Date refDate) {
if (! (isIMMcode(immCode, false)) ) throw new IllegalArgumentException(immCode+" is not a valid IMM code");
Date referenceDate;
if (Date.NULL_DATE.equals(refDate)) {
referenceDate = settings.getEvaluationDate();
} else {
referenceDate = refDate;
}
char code = immCode.charAt(0);
Month m = Month.valueOf(code);
int y = immCode.charAt(1) - '0';
/* year<1900 are not valid QuantLib years: to avoid a run-time
exception few lines below we need to add 10 years right away */
if (y==0 && referenceDate.getYear()<=1909) y+=10;
int yMod = (referenceDate.getYear() % 10);
y += referenceDate.getYear() - yMod;
Date result = nextDate(DateFactory.getFactory().getDate(1, m, y), false);
if (result.lt(referenceDate))
return nextDate(DateFactory.getFactory().getDate(1, m, y+10), false);
return result;
}