i
Calendars
For the calendar object, only service class operations are defined to work with dates, the model class is not necessary because the Deyel data types are used. The service class is predefined in the Deyel SDK and does not need to be downloaded.
Service Class Content
The service allows the following operations to be performed:
Operation |
Description |
Parameters |
---|---|---|
worksDays(start, end) |
Obtains work days between dates, using the current user's calendar or another one specified as a parameter. |
Timestamp start: Period start date
Timestamp end: Period end date |
worksDays(start, end, calendar) |
Obtains work days between dates, using the calendar specified as a parameter. |
Timestamp start: Period start date
Timestamp end: Period end date
Integer calendar: Code of the specified calendar |
convertToTimeZone(date, calendar) |
Converts a date into a specified time zone. |
Timestamp date: Date to convert
Integer calendar: Calendar code with specified time zone |
Example of Use
Examples contain the use of "CalendarService" service class.
1.Service creation
This service is created only once in the rule and is reused in different operations.
CalendarService calendarService = new CalendarService(getApiClient());
|
2.Calculation of work days between dates
In this example, a budget number is read and the number of work days between the budget entry date and the budget due date is calculated.
A budget with the dsNumber "100234" property value of the "Budget" model class is read, using the read(budget) method of the "BudgetService" service class.
With the workDays(start, end) method of the "CalendarService" service class, the number of work days between the dtQuote and dtDue properties values is obtained, from the corresponding getter methods of the "Budget" model class.
BudgetService budgetService = new BudgetService(getApiClient()); String dsNumber = "100234"; Budget budget = new Budget(); budget.setDsNumber(dsNumber); budget = budgetService.read(budget); Timestamp start = new Timestamp(budget.getDtQuote().getTime()); Timestamp end = new Timestamp(budget.getDtDue().getTime()); calendarService.worksDays(start, end);
|
3.Time calculation with another time zone
This example converts local time to Mexico time, set by calendar 2 time zone, using the convertToTimeZone(localTime, 2) method of the "CalendarService" service.
Timestamp localTime = Timestamp.valueOf(LocalDateTime.now()); Timestamp timeMexico = calendarService.convertToTimeZone(localTime, 2); log("Local Time: " + localTime + " Time Mexico: " + timeMexico);
|