Java Day in Month getMonthlyCronExpression(int minutes, int hours, int dayOfMonth)

Here you can find the source of getMonthlyCronExpression(int minutes, int hours, int dayOfMonth)

Description

Generates a cron pattern that will execute every month at the dayOfMonth at hour:minute

License

Open Source License

Parameter

Parameter Description
minutes a parameter
hours a parameter
dayOfMonth a parameter

Return

a cron pattern

Declaration

public static String getMonthlyCronExpression(int minutes, int hours, int dayOfMonth) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*w w w. j a  va  2s .com*/
     * Generates a cron pattern that will execute every month at the dayOfMonth at hour:minute
     *
     * @param minutes
     * @param hours
     * @param dayOfMonth
     * @return a cron pattern
     */
    public static String getMonthlyCronExpression(int minutes, int hours, int dayOfMonth) {
        return getCronExpression("0", String.valueOf(minutes), String.valueOf(hours), String.valueOf(dayOfMonth),
                "*/1", null);
    }

    /**
     * Joins together each segment of a cron pattern into a complete cron pattern.
     *
     * @param seconds a valid cron segment
     * @param minutes a valid cron segment
     * @param hours   a valid cron segment
     * @param days    a valid cron segment
     * @param months  a valid cron segment
     * @param weekday a valid cron segment (MON-SUN)
     * @return a cron pattern
     */
    public static String getCronExpression(String seconds, String minutes, String hours, String days, String months,
            String weekday) {
        return String.join(" ", (seconds == null ? "*" : seconds), (minutes == null ? "*" : minutes),
                (hours == null ? "*" : hours), (days == null ? "*" : days), (months == null ? "*" : months),
                (weekday == null ? "*" : weekday));
    }
}

Related

  1. getMonthDay(int year, int month)
  2. getMonthDayFormats()
  3. getMonthDays(int year, int month)
  4. getMonthDaysArray(int year)
  5. getMonthDayString(long l, boolean timezone, boolean formated)
  6. getMonthOfDayMark(int day)
  7. getNumberOfDaysInMonth(Integer year, Integer month)
  8. getNumberOfDaysInMonthes(int theyear)
  9. getNumDaysInMonth(String monthID, String yearID)