从Notes DateTime对象设置Java日期对象 [英] Set a Java date Object from a Notes DateTime Object
问题描述
处理日期引起了我一些问题.
Manipulating Dates causing me some issues.
我创建了一些Java代码,这些代码从Notes数据库中读取文档,然后使用Notes文档中的值填充Java对象中的某些字段.Notes文档包含一个DataTime字段"ExpPayDate",我想将其存储在Java对象中,但是在Java编辑器中出现语法错误.我的代码如下:
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();
}
我尝试了各种方法来从pDoc getItemValue getItemValueDateTime中获取值上面的代码给出了一个snytax错误,如果类型od表达式必须为bean数组类型,但已解析为Vector",则我删除了[0],错误为类型不匹配,无法将Vector转换为Date"我猜想我遗漏了一些非常简单的东西,但此刻我很困惑.
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.
推荐答案
使用DateTime的 .toJavaDate()
.它将Domino的DateTime值转换为Java的java.util.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();
这篇关于从Notes DateTime对象设置Java日期对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!