for (;;) {
ret.clear();
/*
* First attempt: Take a full date-time format MEDIUM
*/
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, iLocale);
df.parse(image, ret, p);
if (p.getErrorIndex() < 0)
break;
if (!ret.isSet(DAY_OF_MONTH) || !ret.isSet(MONTH)) {
//Try with SHORT format
ret.clear();
df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, iLocale);
p.setIndex(0);
p.setErrorIndex(-1);
df.parse(image, ret, p);
if (!ret.isSet(DAY_OF_MONTH) || !ret.isSet(MONTH)) { // Give up with date
ret.clear();
p.setErrorIndex(0);
}
}
if (ret.isSet(MINUTE))
break;
/*
* If no time found yet (i.e. at least hour+minute like Lotus), try to fish it
*/
p.setIndex(p.getErrorIndex());
p.setErrorIndex(-1);
df = DateFormat.getTimeInstance(DateFormat.MEDIUM, iLocale);
df.parse(image, ret, p);
if (ret.isSet(MINUTE))
break;
if (ret.isSet(DAY_OF_MONTH)) { // Set back possible hour (in accordance with Lotus)
ret.clear(HOUR);
ret.clear(HOUR_OF_DAY);