Working with Calendar Properties
Microsoft Project use calendars and other information to calculate project end dates. Aspose.Tasks for Java supports the calendar functionality. This article illustrates the calendar properties that can be set and shows how they are applied in code.
Calendar Properties The Calendar exposes several properties used to define the base calendar in Microsoft Outlook:
- BaseCalendar – the base calendar. This property supports the Calendar object for reading and writing the base calendar for the current calendar instance and is only applicable if the current calendar instance is not already a base calendar.
- Days – the days of the week that are weekdays. A list of WeekDay objects.
- Name – the calendar’s name. Get or set the property with a string.
- Uid – the calendar’s unique ID. Integer.
- WorkWeeks – a collection of effective work weeks.
The code that follows gets the general calendar properties.
1// The path to the documents directory.
2String dataDir = Utils.getDataDir(CalendarProperties.class);
3
4long OneSec = 10000000;// microsecond * 10
5long OneMin = 60 * OneSec;
6long OneHour = 60 * OneMin;
7
8Project project = new Project(dataDir + "prj.mpp");
9
10for (Calendar cal : project.getCalendars()) {
11 if (cal.getName().toString() != null) {
12 for (WeekDay wd : cal.getWeekDays()) {
13 double ts = wd.getWorkingTime();
14 double time = ts / (OneHour);
15 System.out.println("Day Type" + wd.getDayType() + "Hours" + ts);
16 }
17
18 System.out.println("Base Calendar : ");
19 if (cal.isBaseCalendar())
20 System.out.println("Self");
21 else
22 System.out.println(cal.getBaseCalendar().getName());
23
24 System.out.println("UID : " + cal.getUid());
25 System.out.println("Name : " + cal.getName());
26 }
27}