In your XPages app, you can use an EditBox control and set it’s display type to be a Date/Time control with certain formats. 2 examples are Date only or Time only. This all works great, except when you want to save these values to a Notes Document either via SSJS or Java. The saved values are definitely stored correctly in a Date/Time field, but always contain both a date and time value.

Example

Below is a snippet of an EditBox control set up as a Date Only component in an XPage or Custom control, bound to a Java bean of object type “Date”:

XPage Snippet for Date Only

Your Java logic to save this value to a NotesDocument will look something like this:

Sadly, in the NotesDocument Field Properties tab, the saved value contains both a date and time:

XPages Date Time Value

 

Solution

Thankfully, the solution is very simple. When you create your DateTime object in either Java or JavaScript, before adding it to the doc.replaceItemValue, do the following:

To remove the time from the Date/Time value:

To remove the date from the Date/Time value:

The above java example is very similar to what you would do in SSJS as well.
As simple as that 🙂