* metadata record in Lucene - if exception during parsing then it is
* something ridiculous like JUNK value above
*/
public static String parseISODateTimes(String input1, String input2) {
DateTimeFormatter dto = ISODateTimeFormat.dateTime();
PeriodFormatter p = ISOPeriodFormat.standard();
DateTime odt1;
String odt = "";
// input1 should be some sort of ISO time
// eg. basic: 20080909, full: 2008-09-09T12:21:00 etc
// convert everything to UTC so that we remove any timezone
// problems
try {
DateTime idt = parseBasicOrFullDateTime(input1);
odt1 = dto.parseDateTime(idt.toString()).withZone(
DateTimeZone.forID("UTC"));
odt = odt1.toString();
} catch (Exception e) {
e.printStackTrace();
return DEFAULT_DATE_TIME;
}
if (input2 == null || input2.equals(""))
return odt;
// input2 can be an ISO time as for input1 but also an ISO time period
// eg. -P3D or P3D - if an ISO time period then it must be added to the
// DateTime generated for input1 (odt1)
// convert everything to UTC so that we remove any timezone
// problems
try {
boolean minus = false;
if (input2.startsWith("-P")) {
input2 = input2.substring(1);
minus = true;
}
if (input2.startsWith("P")) {
Period ip = p.parsePeriod(input2);
DateTime odt2;
if (!minus)
odt2 = odt1.plus(ip.toStandardDuration().getMillis());
else
odt2 = odt1.minus(ip.toStandardDuration().getMillis());