Set a Java date Object from a Notes DateTime Object

◇◆丶佛笑我妖孽 提交于 2021-02-04 18:00:04

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/32415752/set-a-java-date-object-from-a-notes-datetime-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!