XPages date only fieldonly

2019-01-28 11:36发布

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);

标签: xpages
2条回答
Rolldiameter
2楼-- · 2019-01-28 11:49

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

查看更多
可以哭但决不认输i
3楼-- · 2019-01-28 11:52

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);
查看更多
登录 后发表回答