Element tp = new Element("timeAndPeriod", defNS);
Element ti = new Element("timeInfo", defNS);
tc.addContent(tp.addContent(ti));
Element time;
DateType startDate = dateRange.getStart();
DateType endDate = dateRange.getEnd();
if (endDate.isPresent()) {
String units = "Days ago";
TimeDuration duration = dateRange.getDuration();
double value = -0.0;
try {
TimeUnit tdayUnit = new TimeUnit("days");
value = duration.getValue(tdayUnit);
} catch (Exception e) {
e.printStackTrace();
}
time = new Element("timeRelative", defNS);
Element begin = new Element("begin", defNS);
begin.setAttribute("units", units);
begin.addContent(Double.toString(value));
time.addContent( begin);
Element end = new Element("end", defNS);
end.setAttribute("units", units);
end.addContent("0");
time.addContent( end);
} else {
// LOOK not tested
time = new Element("timeAD", defNS);
Element begin = new Element("begin", defNS);
begin.setAttribute("date", startDate.toDateString());
time.addContent( begin);
Element end = new Element("end", defNS);
end.setAttribute("date", endDate.toDateString());
time.addContent( end);
}
ti.addContent(time);
return tc;