0

I have defined a TreeMap with Notes DateTime object as key:

import lotus.domino.*;

public TreeMap<DateTime,String> getDateTimeObjects(){
    Session session = Utils.getSession();

    TreeMap<DateTime,String> dtMap = new TreeMap<DateTime,String>();
    DateTime dateTimeObject;
    try {
        dateTimeObject = session.createDateTime("Today");
        dateTimeObject.setNow();
        dtMap.put(dateTimeObject, "Today");

        dateTimeObject = session.createDateTime("Yesterday");
        dtMap.put(dateTimeObject, "Yesterday");

        dateTimeObject= session.createDateTime( "08/18/95 01:36:22 PM" );
        dtMap.put(dateTimeObject, "1995");

        dateTimeObject= session.createDateTime( "12/30/99 03:36:22 PM" );
        dtMap.put(dateTimeObject, "1999");

    } catch (NotesException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return dtMap;
}

but then I get the message:

Script interpreter error, line=1, col=9: Error calling method 'getDateTimeObjects()' on java class 'com.acme.projectX.app.ApplicationBean' lotus.domino.local.DateTime incompatible with java.lang.Comparable

should I write a custom comparator and how to transform the notes datetime to a java datetime in it?

Patrick Kwinten
  • 1,988
  • 2
  • 14
  • 26
  • 3
    You can use .toJavaDate() on the Notes DateTime object to get the Java date. See https://stackoverflow.com/a/32415881/785061 – Per Henrik Lausten Jun 15 '20 at 10:20
  • A custom comparator would be an option but I would go with Per - or transform the datetime to a String which should also be ok – Oliver Busse Jun 15 '20 at 10:22
  • Hi Per, that works well. If you add your comment as an answer I accept it and you get the credits. is there any difference between notes datetime and java datetime? – Patrick Kwinten Jun 15 '20 at 13:17

0 Answers0