Class Dates


  • public class Dates
    extends net.andreinc.mockneat.abstraction.MockUnitBase
    • Constructor Detail

      • Dates

        public Dates()
    • Method Detail

      • futureDate

        public static String futureDate​(String startDate,
                                        int daysToAdd,
                                        String dateFormat)
        Returns a string that represents the date that is the given days ahead of the start date
        Parameters:
        startDate - start date
        daysToAdd - days to add to start date
        dateFormat - date format (e.g. "dd/MM/yyyy","dd/MM/yyyy HH:mm")
        Returns:
        String representing resulting date
      • pastDate

        public static String pastDate​(String startDate,
                                      int daysToRemove,
                                      String dateFormat)
        Returns a string that represents the date that is the given days behind of the start date
        Parameters:
        startDate - start date
        daysToRemove - days to remove from start date
        dateFormat - date format (e.g. "dd/MM/yyyy","dd/MM/yyyy HH:mm")
        Returns:
        String representing resulting date
      • now

        public static String now​(String dateFormat)
        Returns the current date for today
        Parameters:
        dateFormat - date format (e.g. "dd/MM/yyyy","dd/MM/yyyy HH:mm")
        Returns:
        String representing resulting date
      • futureDateAvoidingWeekends

        public static String futureDateAvoidingWeekends​(String startDate,
                                                        int numberOfBusinessDaysToAdd,
                                                        String dateFormat)
        Parameters:
        startDate - the date to start with
        numberOfBusinessDaysToAdd - Days to add, avoiding weekends
        dateFormat - date format (e.g. "dd/MM/yyyy","dd/MM/yyyy HH:mm"")
        Returns:
        String representing resulting date
      • futureDataAvoidingWeekendsAndBankHolidays

        public static String futureDataAvoidingWeekendsAndBankHolidays​(Locale locale,
                                                                       String startDate,
                                                                       int numberOfBusinessDaysToAdd,
                                                                       String dateFormat)
                                                                throws IOException
        Parameters:
        locale - the location for UK bank holidays (see @link Dates)
        startDate - the date to start with
        numberOfBusinessDaysToAdd - Days to add, avoiding weekends and UK bank holidays
        dateFormat - date format (e.g. "dd/MM/yyyy","dd/MM/yyyy HH:mm")
        Returns:
        String representing resulting date
        Throws:
        IOException - if the JSON source for bank holidays cannot be read