Manipulating Dates causing me some issues.
I've created some Java code that reads a document from a Notes DB then populates some fields in a Java Object with values from the Notes Document. The Notes Document contains a DataTime field "ExpPayDate" and I want to store it in the Java Object, but get a syntax error in the Java Editor. My code looks like this:
for (int n = 1 ; n < col.getCount(); n++){
Document pDoc = col.getNthDocument(n);
PaymentItem pItem = new PaymentItem();
Date pDate = pDoc.getItemValue("ExpPayDate")[0];
pItem.setExpPayDate(pDate);
.
.
.
pDoc.recycle();
}
I have tried various ways to get the value from pDoc getItemValue getItemValueDateTime The above code gives a snytax error "the type od expression must bean array type but is resolved to Vector" if I remove the [0] the error is "type mismatch can not convert Vector to Date" I'm guessing that I'm missing something pretty simple but it has me stumped at the moment.
The setTime() method of Java Date class sets a date object. It sets date object to represent time milliseconds after January 1, 1970 00:00:00 GMT. Parameters: The function accepts a single parameter time which specifies the number of milliseconds. Return Value: It method has no return value.
Calendar to initialize date: Calendar calendar = Calendar. getInstance(); //To Initialize Date to current Date Date date = calendar. getTime(); //To Initialize Date to a specific Date of your choice (here I'm initializing the date to 2022-06-15) calendar.
Using Date Class The pattern required by the user is specified while creating the SimpleDateFormat instance. The usage of format() method of the DateFormat class is made to pass the date object as a parameter to the method. DateFormat dform = new SimpleDateFormat( "dd/MM/yy HH:mm:ss" ); Date obj = new Date();
Use DateTime's .toJavaDate()
. It converts Domino's DateTime value to Java's java.util.Date.
DateTime dateTime = (DateTime) pDoc.getItemValueDateTimeArray("ExpPayDate").get(0);
Date pDate = dateTime.toJavaDate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With