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.
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”:
Your Java logic to save this value to a NotesDocument will look something like this:
DateTime tempDate = null; tempDate = session.createDateTime(bean.dateOnly); doc.replaceItemValue("DateOnly", tempDate);
Sadly, in the NotesDocument Field Properties tab, the saved value contains both a date and time:
To remove the time from the Date/Time value:
tempDate = session.createDateTime(bean.dateOnly); tempDate.setAnyTime();//This removes the time value doc.replaceItemValue("DateOnly", tempDate);
To remove the date from the Date/Time value:
tempDate = session.createDateTime(bean.timeOnly); tempDate.setAnyDate();//This removes the date value doc.replaceItemValue("TimeOnly", tempDate);
The above java example is very similar to what you would do in SSJS as well.
As simple as that