public static int createScheduleForProcessDef(String url, long processDefCode,
            String token, ScheduleInfo scheduleInfo) throws Exception {

        try {
            Map<String, String> header = buildHeader(token);

            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DS_DEFAULT_SCHEDULE_TIME_FORMAT);
            String startTime = scheduleInfo.getStartTime().toLocalDateTime()
                    .atZone(ZoneId.of(DS_DEFAULT_TIMEZONE_ID)).format(formatter);
            String endTime = scheduleInfo.getEndTime().toLocalDateTime()
                    .atZone(ZoneId.of(DS_DEFAULT_TIMEZONE_ID)).format(formatter);

            String crontab;
            switch (scheduleInfo.getScheduleType()) {
                case 0:
                    crontab = generateCrontabExpression(scheduleInfo.getScheduleUnit(),
                            scheduleInfo.getScheduleInterval());
                    break;

                case 1:
                    crontab = scheduleInfo.getCrontabExpression();
                    break;

                default:
                    LOGGER.error("Unsupported schedule type: {}", scheduleInfo.getScheduleType());
                    throw new DolphinScheduleException("Unsupported schedule type: " + scheduleInfo.getScheduleType());
            }

            DScheduleInfo dScheduleInfo = new DScheduleInfo();
            dScheduleInfo.setStartTime(startTime);
            dScheduleInfo.setEndTime(endTime);
            dScheduleInfo.setCrontab(crontab);
            dScheduleInfo.setTimezoneId(DS_DEFAULT_TIMEZONE_ID);
            String scheduleDef = MAPPER.writeValueAsString(dScheduleInfo);

            Map<String, String> queryParams = new HashMap<>();
            queryParams.put(DS_PROCESS_CODE, String.valueOf(processDefCode));
            queryParams.put(DS_SCHEDULE_DEF, scheduleDef);

            JsonObject response = executeHttpRequest(url, POST, queryParams, header);
            LOGGER.info("create schedule for process definition success, response data: {}", response);

            return response.get(DS_RESPONSE_DATA).getAsJsonObject().get(DS_ID).getAsInt();

        } catch (JsonParseException e) {
            LOGGER.error("JsonParseException during releasing process definition", e);
            throw new DolphinScheduleException(
                    JSON_PARSE_ERROR,
                    String.format("Error creating schedule for process definition code: %d at URL: %s",
                            processDefCode, url));

        } catch (DolphinScheduleException e) {
            throw new DolphinScheduleException(
                    SCHEDULE_CREATION_FAILED,
                    String.format("Error creating schedule for process definition code: %d at URL: %s",
                            processDefCode, url));
        }
    }
Create a schedule for process definition in DolphinScheduler.

@param url The URL to create a schedule for the process definition.
@param processDefCode The ID of the process definition.
@param token          The authentication token to be used in the request header.
@param scheduleInfo    The schedule info
@return The schedule id
inlong-manager/manager-schedule/src/main/java/org/apache/inlong/manager/schedule/dolphinscheduler/DolphinScheduleUtils.java