Class SchedulerTimeUtils


  • public class SchedulerTimeUtils
    extends Object
    Provides utility methods that help to deal with dates when scheduling a process.
    • Method Detail

      • timestamp

        public static Date timestamp​(String dateTime)
                              throws ParseException
        Utility method to parse a date with time String into a Date.
        Parameters:
        dateTime - A date with time as a String. Expected format: 'dd-MM-yyyy HH:mm:ss' If missing, current date and time is returned.
        Returns:
        a Date with the provided date and time.
        Throws:
        ParseException - if the provided date and time can not be parsed to create the Date instance.
      • getCurrentDateTime

        public static String getCurrentDateTime​(String date,
                                                String time)
        Returns current DateTime as formatted String to be used in the parse/timestamp method If date or time is missing, it will assume now for that part, if both are present it will keep them
        Parameters:
        date - Date in format dd-MM-yyyy
        time - Time in format HH:mm:ss
        Returns:
        Current DateTime as String formatted as "dd-MM-yyyy HH:mm:ss", if any parameter missing, it will assume current
      • currentDate

        public static String currentDate​(String format)
        Formats the current date using a specific format.
        Parameters:
        format - the date time format to be applied.
        Returns:
        a String with the current date time formatted with the provided format.
      • format

        public static String format​(Date date,
                                    String format)
        Formats the provided date using a specific format.
        Parameters:
        format - the date time format to be applied.
        Returns:
        a String with the date formatted with the provided format.