• DateTime.timeDifference(DateTime dt) ==> ambiguous for type DateTime

    By Mario Eppig 9 years ago

    I don't know yet if this issue has been fixed with the latest release, but DateTime.timeDifference(DateTime) is ambigious for the type DateTime.

    I worked around by converting both dates to java dates and subtracting their time values.

    • By Maire Kehoe 9 years ago

      Hi. Sorry, but can you provide more information about the exact problem, please.
      This SSJS code seems to work for me, without any exceptions:

      var nowDate = new java.util.Date();
      
      var laterNumber = nowDate.getTime()+ (1000*60*60*2);
      var laterDate = new java.util.Date(laterNumber);
      
      var nowDateTime = session.createDateTime(nowDate);
      var laterDateTime = session.createDateTime(laterDate);
      
      var duration = laterDateTime.timeDifference(nowDateTime);
      
      • By Mario Eppig 9 years ago

        Hey,

        works flawlessly in ssjs indeed, but i get an error message when trying to use this method in java.

        Here is my piece of code:

        package org.openntf;
        
        import org.openntf.domino.DateTime;
        import org.openntf.domino.Session;
        import org.openntf.domino.utils.XSPUtil;
        
        public class Test {
        
            public Test() {
                Session s = XSPUtil.getCurrentSession();
                DateTime d1 = s.createDateTime(2015, 1, 1, 0, 0, 0);
                DateTime d2 = s.createDateTime(2014, 1, 1, 0, 0, 0);
        
                if (d1.timeDifference(d2) > 0) {
        
                }
            }
        }
        

        • By Maire Kehoe 9 years ago

          Ah, that explains it. You're using org.openntf.domino.DateTime,
          which is part of the Open Domino API project:
          http://www.openntf.org/main.nsf/project.xsp?r=project/OpenNTF%20Domino%20API/summary
          where as the SSJS code is using lotus.domino.DateTime.
          Try reporting the issue to that project's forum, as it's not part of the XPages Extension Library (this project).
          Best of luck with it.