/**
* Create a table cell with a date as data.
*/
private void createTableCellWithDateLinks(String data, String niceDate, Phrase phrase2) {
Phrase phrase;
int ndSpace1 = niceDate.indexOf(' ');
int ndSpace2 = ndSpace1 < 0 ? -1 : niceDate.indexOf(' ', ndSpace1 + 1);
String dayMonth = data.substring(0, data.lastIndexOf('.'));
String year = data.substring(data.lastIndexOf('.') + 1);
if (!dayMonth.contains("?")) {
Anchor anchor = new Anchor(new Phrase(niceDate.substring(0, ndSpace2 < 0 ? niceDate.length() : ndSpace2)));
anchor.setReference("#dm-" + dayMonth);
phrase2.add(anchor);
}
else {
phrase =
new Phrase(year.contains("?") ? niceDate : niceDate.substring(0, Math.max(0, Math.max(ndSpace1, ndSpace2))));
phrase2.add(phrase);
}
phrase = new Phrase(" ");
phrase2.add(phrase);
if (!year.contains("?")) {
Anchor anchor = new Anchor(new Phrase(year));
anchor.setReference("#y-" + year);
phrase2.add(anchor);
}
else {
phrase = new Phrase(year);
phrase2.add(phrase);
}
}