Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPages date only fieldonly

Tags:

xpages

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);
like image 923
Martin Perrie Avatar asked Nov 19 '25 17:11

Martin Perrie


2 Answers

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

like image 194
Simon O'Doherty Avatar answered Nov 22 '25 06:11

Simon O'Doherty


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);
like image 33
Panu Haaramo Avatar answered Nov 22 '25 07:11

Panu Haaramo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!