public Duration getTotalSlack()
   {
      Duration totalSlack = (Duration) getCachedValue(TaskField.TOTAL_SLACK);
      if (totalSlack == null)
      {
         Duration duration = getDuration();
         if (duration == null)
         {
            duration = Duration.getInstance(0, TimeUnit.DAYS);
         }

         TimeUnit units = duration.getUnits();

         Duration startSlack = getStartSlack();
         if (startSlack == null)
         {
            startSlack = Duration.getInstance(0, units);
         }
         else
         {
            if (startSlack.getUnits() != units)
            {
               startSlack = startSlack.convertUnits(units, getParentFile().getProjectProperties());
            }
         }

         Duration finishSlack = getFinishSlack();
         if (finishSlack == null)
         {
            finishSlack = Duration.getInstance(0, units);
         }
         else
         {
            if (finishSlack.getUnits() != units)
            {
               finishSlack = finishSlack.convertUnits(units, getParentFile().getProjectProperties());
            }
         }

         double startSlackDuration = startSlack.getDuration();
         double finishSlackDuration = finishSlack.getDuration();

         if (startSlackDuration == 0 || finishSlackDuration == 0)
         {
            if (startSlackDuration != 0)
            {
               totalSlack = startSlack;
            }
            else
            {
               totalSlack = finishSlack;
            }
         }
         else
         {
            if (startSlackDuration < finishSlackDuration)
            {
               totalSlack = startSlack;
            }
            else
            {
               totalSlack = finishSlack;
            }
         }

         set(TaskField.TOTAL_SLACK, totalSlack);
      }

      return (totalSlack);
   }
public Duration getTotalSlack ( ) { Duration totalSlack = ( Duration ) getCachedValue ( TaskField . TOTAL_SLACK ) ; if ( totalSlack == null ) { Duration duration = getDuration ( ) ; if ( duration == null ) { duration = Duration . getInstance ( 0 , TimeUnit . DAYS ) ; } TimeUnit units = duration . getUnits ( ) ; Duration startSlack = getStartSlack ( ) ; if ( startSlack == null ) { startSlack = Duration . getInstance ( 0 , units ) ; } else { if ( startSlack . getUnits ( ) != units ) { startSlack = startSlack . convertUnits ( units , getParentFile ( ) . getProjectProperties ( ) ) ; } } Duration finishSlack = getFinishSlack ( ) ; if ( finishSlack == null ) { finishSlack = Duration . getInstance ( 0 , units ) ; } else { if ( finishSlack . getUnits ( ) != units ) { finishSlack = finishSlack . convertUnits ( units , getParentFile ( ) . getProjectProperties ( ) ) ; } } double startSlackDuration = startSlack . getDuration ( ) ; double finishSlackDuration = finishSlack . getDuration ( ) ; if ( startSlackDuration == 0 || finishSlackDuration == 0 ) { if ( startSlackDuration != 0 ) { totalSlack = startSlack ; } else { totalSlack = finishSlack ; } } else { if ( startSlackDuration < finishSlackDuration ) { totalSlack = startSlack ; } else { totalSlack = finishSlack ; } } set ( TaskField . TOTAL_SLACK , totalSlack ) ; } return ( totalSlack ) ; }
The Total Slack field contains the amount of time a task can be
delayed without delaying the project's finish date.

@return string representing duration