none
[E2010] [EWS Java API 1.1][JAVA] - DateCompleted set in the task is not taking effect if status is set as Completed. RRS feed

  • Question

  • Hi,

    I am trying to create a Task. In the Task if I set only the DateCompleted field, then the Date is set correctly.

            ExchangeService service = new ExchangeService();
            service.setUrl( new URI( "http://<server-ip>/ews/Exchange.asmx" ) );
            service.setCredentials( new WebCredentials( "username", "password" ) );
    
            List < Item > items = new ArrayList < Item >();
            Task task = new Task( service );
    
            Calendar calendar = Calendar.getInstance();
            calendar.set( Calendar.YEAR, 2005 );
            calendar.set( Calendar.MONTH, 3 );
            calendar.set( Calendar.DATE, 15 );
            Date time = calendar.getTime();
            task.setCompleteDate( time );
    
            items.add( task );
    
            System.out.println( task.getId() );
    
            service.createItems( items, new FolderId( WellKnownFolderName.Tasks ), MessageDisposition.SaveOnly,
                    SendInvitationsMode.SendToNone );
    
            Task createdTask = Task.bind( service, task.getId() );
            System.out.println( createdTask.getCompleteDate() );
    
            System.out.println( task.getId() );


    Here the CompleteDate (Fri Apr 15 15:00:14 IST 2005) is coming correctly. But if I set the status as completed, then the Date is set to the current time.

            ExchangeService service = new ExchangeService();
            service.setUrl( new URI( "http://<server-ip>/ews/Exchange.asmx" ) );
            service.setCredentials( new WebCredentials( "username", "password" ) );
    
            List < Item > items = new ArrayList < Item >();
            Task task = new Task( service );
    
            Calendar calendar = Calendar.getInstance();
            calendar.set( Calendar.YEAR, 2005 );
            calendar.set( Calendar.MONTH, 3 );
            calendar.set( Calendar.DATE, 15 );
            Date time = calendar.getTime();
            task.setCompleteDate( time );
            
            task.setStatus( TaskStatus.Completed );
            items.add( task );
    
            System.out.println( task.getId() );
    
            service.createItems( items, new FolderId( WellKnownFolderName.Tasks ), MessageDisposition.SaveOnly,
                    SendInvitationsMode.SendToNone );
    
            Task createdTask = Task.bind( service, task.getId() );
            System.out.println( createdTask.getCompleteDate() );
    
            System.out.println( task.getId() );


    Now the printed date is Tue Jan 17 09:32:20 IST 2012. It is the current date. But I want to set the CompleteDate as another time.

    Has anyone faced and worked around this issue? Please help.

    Thanks,

    Paul

     

    Tuesday, January 17, 2012 9:33 AM

All replies