我要取文档的创建时间 根据创建时间排序 用Java代码怎么取创建时间啊??
文档随便建个域,创建时计算,@CREATED。不就有了吗
在JAVA代理中获取创建时间?
SimpleDateFormat s = new SimpleDateFormat("YY-MM-DD hh:mm:ss");
Vector createTime = doc.getItemValue("创建时间域名");
String createTimeStr = "";
if(createTime.size()!=0)
{
createTimeStr = s.format(((DateTime)createTime.elementAt(0)).toJavaDate());
}
帮助里面都有,代码如下:
Java code
import lotus.domino.*;
import java.util.Vector;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
DocumentCollection dc = db.getAllDocuments();
Document doc = dc.getFirstDocument();
while (doc != null) {
System.out.println(doc.getItemValueString("Subject"));
System.out.println("\tCreated on " +
doc.getCreated().getLocalTime());
System.out.println("\tLast accessed on " +
doc.getLastAccessed().getLocalTime());
System.out.println("\tLast modified on " +
doc.getLastModified().getLocalTime());
doc = dc.getNextDocument(doc); }
} catch(Exception e) {
e.printStackTrace();
}
}
}