// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java // The path to the documents directory. String dataDir = Utils.getDataDir(TaskDurationInDifferentUnits.class); // Read MS Project template file String fileName = dataDir + "SampleProject.mpp"; // Read the input file as Project Project project = new Project(fileName); // Get a task to calculate its duration in different formats Task task = project.getRootTask().getChildren().getById(1); // Get the duration in Minutes double mins = task.get(Tsk.DURATION).convert(TimeUnitType.Minute).toDouble(); // Get the duration in Days double days = task.get(Tsk.DURATION).convert(TimeUnitType.Day).toDouble(); // Get the duration in Hours double hours = task.get(Tsk.DURATION).convert(TimeUnitType.Hour).toDouble(); // Get the duration in Weeks double weeks = task.get(Tsk.DURATION).convert(TimeUnitType.Week).toDouble(); // Get the duration in Months double months = task.get(Tsk.DURATION).convert(TimeUnitType.Month).toDouble();