Thursday, September 19, 2013

Strange implementation of Document.setPreferJavaDates( true )

I wanted to try the Document.setPreferJavaDates today and see how it worked.

I called Document.setPreferJavaDates( true ); to ensure that no (Notes)DateTime objects were created as I didn't need them/didn't want to deal with recycling.

First I tried:
Document.getItemValueDateTimeArray( "fieldname" );
This returned a Vector of DateTime.

Then I tried:
Document.getItemValue( "fieldname" );
This also returned a Vector of DateTime.

The way that finally worked as expected (returned a Vector of java.util.Date) was this:
Document.firstItem( "fieldname" ).getValues();

I would imagine this is the least used method among developers wanting to get a date value from a field. This code was executed on a server running Domino 8.5.3FP2

2 comments:

Nathan Freeman said...

LOL. I'm sorry Tommy, but... ahahahahahaha. Yeah, the switch doesn't violate the contract rules of the Java interfaces in lotus.domino. It can't. And therefore it never, ever, ever, ever works the way any smart person such as yourself would expect.

org.openntf.domino

But I don't have to tell you that, do I? ;-)

Tommy Valand said...

It wouldn't break the contract of getItemValue..?

The app I was doing it in is more or less 100% SSJS (doing maintenance).

To use org.openntf.domino would require some work (or very verbose code) I would imagine..?