If you know the Item only contains a single DateTime, never multiple values and never DateRanges, adminfd's answer should work.
Otherwise it's more complex, as you will see from looking at Document.getItemValueDateTimeArray()
in OpenNTF Domino API. The code (albeit Java) from M5 is appended below.
Bear in mind also that recycling doc
or item
will not recycle the resulting DateTime object. If you're getting DateTimes in a loop, you'll need to use validDominoBase.recycle(dateVar)
, where validDominoBase is any Domino object that has not yet been recycled.
@Override
public Vector<org.openntf.domino.Base<?>> getItemValueDateTimeArray(final String name) { // cf. DateRange.java
checkMimeOpen();
boolean mayBeMime = true;
Vector<org.openntf.domino.Base<?>> vGIV = null; // see below
try {
Vector<?> v = getDelegate().getItemValueDateTimeArray(name);
mayBeMime = false;
if (v == null || v.size() == 0)
return (Vector<org.openntf.domino.Base<?>>) v;
FactorySchema<?, ?, Session> schema = DateTime.SCHEMA;
if (v.elementAt(0) instanceof lotus.domino.DateRange) // at moment: never
schema = DateRange.SCHEMA;
else { // Workaround for Vector of DateRange-s
while (true) {
int sz = v.size(), i;
for (i = 0; i < sz; i++)
if (v.elementAt(i) != null)
break;
if (i < sz)
break;
vGIV = getDelegate().getItemValue(name);
if (vGIV.size() != sz * 2)
break;
for (i = 0; i < sz * 2; i++)
if (!(vGIV.elementAt(i) instanceof lotus.domino.DateTime))
break;
if (i < sz * 2)
break;
Vector<lotus.domino.DateRange> aux = new Vector<lotus.domino.DateRange>(sz);
lotus.domino.Session rawsession = toLotus(Factory.getSession());
for (i = 0; i < sz; i++) {
lotus.domino.DateTime dts = (lotus.domino.DateTime) vGIV.elementAt(2 * i);
lotus.domino.DateTime dte = (lotus.domino.DateTime) vGIV.elementAt(2 * i + 1);
lotus.domino.DateRange dr = rawsession.createDateRange(dts, dte);
aux.add(dr);
}
v = aux;
schema = DateRange.SCHEMA;
break;
}
}
return (Vector<org.openntf.domino.Base<?>>) fromLotusAsVector(v, schema, getAncestorSession());
} catch (NotesException e) {
while (mayBeMime) {
MIMEEntity entity = this.getMIMEEntity(name);
if (entity == null)
break;
Object mim = null;
try {
mim = Documents.getItemValueMIME(this, name, entity);
} finally {
closeMIMEEntities(false, name);
}
if (mim == null)
break;
Vector<?> v;
if (mim instanceof Vector)
v = (Vector<Object>) mim;
else if (mim instanceof Collection)
v = new Vector<Object>((Collection<Object>) mim);
else if (mim.getClass().isArray())
v = (Vector<Object>) Arrays.asList((Object[]) mim);
else
break;
int sz = v.size(), i;
for (i = 0; i < sz; i++) {
Object o = v.elementAt(i);
if (o == null)
break;
if ((!(o instanceof DateTime)) && (!(o instanceof DateRange)))
break;
}
if (i < sz)
break;
return (Vector<org.openntf.domino.Base<?>>) v;
}
DominoUtils.handleException(e);
return null;
} finally {
if (vGIV != null)
Base.s_recycle(vGIV);
}
}