Martin Perrie
Martin Perrie

Reputation: 410

XPages date only fieldonly

Is it possible to create a date only field in XPages? I have tried the following in the querySaveDocument event but the field still ends up with a time portion of 00:00:00

var notesDoc:NotesDocument = document1.getDocument();
var dt:NotesDateTime = session.createDateTime(@Today());
dt.setAnyTime();
notesDoc.replaceItemValue("MyDateField", dt);

Upvotes: 3

Views: 2514

Answers (2)

Panu Haaramo
Panu Haaramo

Reputation: 2932

Here is code by Sven:

ndt = session.createDateTime(ndt.getDateOnly());
item.setDateTimeValue(ndt);

error in date items, daylight Saving

Update:

I had to do the same thing and found out that it's working this way in Java agent in 8.5.2FP3:

DateTime dt = session.createDateTime(new java.util.Date());
dt.setAnyTime();
doc.appendItemValue("DT", dt);

Upvotes: 2

Simon O'Doherty
Simon O'Doherty

Reputation: 9349

It is not completely clear what you are trying achieve.

You can put an EditBox component on your XPage, then go to the "Data" tab. From there you can change the formatting from String to Date. More options should appear on how to format the date in the field. It will handle passing the date to the back end document.

Data Properties Tab

If it is you want to write directly to the back end document, then here is a page listing samples on working with NotesDateTime.

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesDateTime_sample_JavaScript_code_for_XPages

Upvotes: 3

Related Questions