다른 단위의 작업 시간을 계산하십시오

몇 분, 시간 등과 같은 다른 단위로 작업의 지속 시간을 계산하는 것이 유용 할 수 있습니다.

지속 시간 계산 task 클래스 제안은 다른 단위로 작업 지속 시간을 계산하기위한 getDuration () 메소드를 제공합니다. 이 방법은 TimeUnittype를 입력 인수로 사용하고 지속 시간을 이중 값으로 반환합니다.

다음 코드는이 방법을 사용하여 미세한 단위로 작업의 지속 시간을 검색하는 방법을 보여줍니다 : 분, 주, 시간, 주 및 월.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(TaskDurationInDifferentUnits.class);
 4
 5// Read MS Project template file
 6String fileName = dataDir + "SampleProject.mpp";
 7
 8// Read the input file as Project
 9Project project = new Project(fileName);
10
11// Get a task to calculate its duration in different formats
12Task task = project.getRootTask().getChildren().getById(1);
13
14// Get the duration in Minutes
15double mins = task.get(Tsk.DURATION).convert(TimeUnitType.Minute).toDouble();
16// Get the duration in Days
17double days = task.get(Tsk.DURATION).convert(TimeUnitType.Day).toDouble();
18// Get the duration in Hours
19double hours = task.get(Tsk.DURATION).convert(TimeUnitType.Hour).toDouble();
20// Get the duration in Weeks
21double weeks = task.get(Tsk.DURATION).convert(TimeUnitType.Week).toDouble();
22// Get the duration in Months
23double months = task.get(Tsk.DURATION).convert(TimeUnitType.Month).toDouble();
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.