Class Dates

java.lang.Object
net.andreinc.mockneat.abstraction.MockUnitBase
com.version1.testdata.Dates

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

    • Dates

      public Dates()
  • Method Details

    • 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
    • isDateWithinTolerance

      public static boolean isDateWithinTolerance(String dateFormat, String baseDate, String comparisonDate, long toleranceInMinutes)
      Returns boolean result on if the two given dates are within the given tolerance
      Parameters:
      dateFormat -
      baseDate -
      comparisonDate -
      toleranceInMinutes -
      Returns:
    • 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