Class fDATE


  • public class fDATE
    extends Object
    date functions
    • Constructor Detail

      • fDATE

        public fDATE()
    • Method Detail

      • AddDaysToDate

        public static Date AddDaysToDate​(Date xDate,
                                         int xDays)
        returns the date on which have added days
        Parameters:
        xDate - the date to which should be added the days
        xDays - the number of days to add to the date
      • AddEasterDayInHolidays

        public static boolean AddEasterDayInHolidays​(int xYear,
                                                     boolean xAddEasterMonday)
        inserts easter days in holidays returns [true] if the upload was successful, otherwise [false]
      • AddMonthsToDate

        public static Date AddMonthsToDate​(Date xDate,
                                           int xMonths)
        returns the date on which have added months
        Parameters:
        xDate - the date to which should be added the months
        xMonths - the number of months to add to the date
      • AddYearsToDate

        public static Date AddYearsToDate​(Date xDate,
                                          int xYears)
        returns the date on which have added years
        Parameters:
        xDate - the date to which should be added the years
        xYears - the number of years to add to the date
      • Age

        public static int Age​(Date xBirthDate)
        returns the age (years) from the birthdate
      • CountHolidaysFromDates

        public static int CountHolidaysFromDates​(Date xStartDate,
                                                 Date xEndDate)
        returns the number of holidays between two dates
        Parameters:
        xStartDate - the start date
        xEndDate - the end date
      • CountWeekdayInMonth

        public static int CountWeekdayInMonth​(int xWeekday,
                                              Date xDate)
        returns the number of times the weekday of the month
        Parameters:
        xWeekday - 1 = sunday, 2 = monday, ..., 7 = saturday
        xDate - an date of the month
      • CountWorkdaysFromDates

        public static int CountWorkdaysFromDates​(Date xStartDate,
                                                 Date xEndDate,
                                                 int xMode)
        returns the number of working days between two dates
        Parameters:
        xStartDate - the start date
        xEndDate - the end date
        xMode - 0 = normal, 1 = keep holidays, 2 = keep weekends, 3 = keep holidays and weekends
      • DateDiff

        public static long DateDiff​(Date xDate1,
                                    Date xDate2,
                                    String xInterval,
                                    boolean xAbsoluteValue)
        returns a value corresponding to the number of time intervals between two dates
        Parameters:
        xDate1 - the date 1
        xDate2 - the date 2
        xInterval - "y" = years, "m" = months, "d" days, "h" = hours, "n" = minutes, "s" = seconds, "!" = milliseconds
        xAbsoluteValue - 'true' = absolute value, 'false' = none
      • DateFromYMD

        public static Date DateFromYMD​(int year,
                                       int month,
                                       int day)
        returns the date corresponding to the settings of the year, month and day
      • DateFromYMDHMS

        public static Date DateFromYMDHMS​(int year,
                                          int month,
                                          int day,
                                          int hour,
                                          int minute,
                                          int second)
        returns the date corresponding to the settings of the year, month, day, hour, minute and second
      • DatestringToDate

        public static Date DatestringToDate​(String xDateString)
        converts a datestring to a date
        Parameters:
        xDateString - the datestring to be converted returns the date, 'Null' is date not valid or error
      • DateToDatestring

        public static String DateToDatestring​(Date xDate)
        converts a date to a datestring
        Parameters:
        xDate - the date to be converted returns the date in string format, 'Null' is date not valid or error
      • Day

        public static int Day​(Date xDate)
        returns the day of the month
      • DaysInMonth

        public static int DaysInMonth​(int xYear,
                                      int xMonth)
        returns the days number of the month
      • EasterDate

        public static Date EasterDate​(int xYear)
        returns the easter date
      • FindDateNextWeekday

        public static Date FindDateNextWeekday​(int xWeekday,
                                               Date xDate)
        returns the date found of the next weekday
        Parameters:
        xWeekday - the day of week (1 = sunday, 2 = monday, ..., 7 = saturday)
        xDate - the date from which to search
      • FindDatePreviousWeekday

        public static Date FindDatePreviousWeekday​(int xWeekday,
                                                   Date xDate)
        returns the date found of the previous weekday
        Parameters:
        xWeekday - the day of week (1 = sunday, 2 = monday, ..., 7 = saturday)
        xDate - the date from which to search
      • FirstDateOfCurrentWeek

        public static Date FirstDateOfCurrentWeek()
        returns the date of the first day of the current week
      • FirstDateOfMonth

        public static Date FirstDateOfMonth​(Date xDate)
        returns the date of the first day of the month
      • FirstDateOfQuarter

        public static Date FirstDateOfQuarter​(Date xDate)
        returns the date corresponding to the first day of a quarter
      • FirstDateOfWeek

        public static Date FirstDateOfWeek​(Date xDate)
        returns the date of the first day of the week
      • FirstDateOfYearWeek

        public static Date FirstDateOfYearWeek​(int xWeek,
                                               int xYear)
        returns the date on the first day of the 'n' year week (0-51)
      • FirstWorkdayNameOfMonth

        public static String FirstWorkdayNameOfMonth​(Date xDate,
                                                     int xMode,
                                                     boolean Shortname)
        returns the name of the first workday of the month
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • FirstWorkdayOfMonth

        public static Date FirstWorkdayOfMonth​(Date xDate,
                                               int xMode)
        returns the date of the first workday of the month
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • GetDateFormat

        public static String GetDateFormat()
        returns the date format in use (default is "dd/MM/yyyy")
      • GetFirstWeekday

        public static int GetFirstWeekday()
        returns the first weekday (1 = sunday *default*, 2 = monday, ..., 7 = saturday)
      • GetHolidays

        public static String[] GetHolidays()
        returns an string array containing all holidays allocated in memory (item format = "MMDD")
      • InsertNewHolidayInMemory

        public static boolean InsertNewHolidayInMemory​(int xMonth,
                                                       int xDay)
        inserts a new holiday in memory (item format = "MMDD") WARNING: not historicizes in external file returns [true] if the insert was successful, otherwise [false]
      • IsDate

        public static boolean IsDate​(Date xDate)
        returns [true] if the date is valid, otherwise [false]
        Parameters:
        xDate - the date to be checked
      • IsDatestring

        public static boolean IsDatestring​(String xDatestring)
        returns [true] if the datestring is valid, otherwise [false]
        Parameters:
        xDateString - the datestring to be checked
      • IsHoliday

        public static boolean IsHoliday​(Date xDate)
        returns [true] if the date is a holiday, otherwise [false]
      • IsWeekend

        public static boolean IsWeekend​(Date xDate)
        returns [true] if the date is a weekend, otherwise it returns [false]
      • LastDateOfMonth

        public static Date LastDateOfMonth​(Date xDate)
        returns the date of the last day of the month
      • LastDateOfQuarter

        public static Date LastDateOfQuarter​(Date xDate)
        returns the date corresponding to the last day of a quarter
      • LastDateOfWeek

        public static Date LastDateOfWeek​(Date xDate)
        returns the date corresponding to the last day of the week
      • LastDayOfMonth

        public static int LastDayOfMonth​(Date xDate)
        returns the last day of the month
      • LastWorkdayNameOfMonth

        public static String LastWorkdayNameOfMonth​(Date xDate,
                                                    int xMode,
                                                    boolean Shortname)
        returns the name of the last workday of the month
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • LastWorkdayOfMonth

        public static Date LastWorkdayOfMonth​(Date xDate,
                                              int xMode)
        returns the date of the last workday of the month
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • LoadHolidaysFromFile

        public static boolean LoadHolidaysFromFile​(String xFileName)
        loads the text file that contains the holidays, each line of text is a single holiday (use "MMDD" format) returns [true] if the upload was successful, otherwise [false]
      • Month

        public static int Month​(Date xDate)
        returns the month of the date
      • MonthName

        public static String MonthName​(Date xDate,
                                       boolean xShortname)
        returns the month name of the date
      • NextAnniversary

        public static Date NextAnniversary​(Date xDate)
        returns the date of the next anniversary
      • NextDate

        public static Date NextDate​(Date xDate)
        returns the next date (24 hours later), 'Null' is date not valid or error
      • NextDay

        public static int NextDay​(Date xDate)
        returns the next day
      • NextMonth

        public static int NextMonth​(Date xDate)
        returns the next month
      • NextMonthName

        public static String NextMonthName​(Date xDate,
                                           boolean xShortname)
        returns the next month name
      • NextWeekday

        public static int NextWeekday​(Date xDate)
        returns the next weekday (1 = sunday, 2 = monday, ..., 7 = saturday)
      • NextWeekdayName

        public static String NextWeekdayName​(Date xDate,
                                             boolean xShortname)
        returns the day name of the next weekday
      • NextWorkday

        public static Date NextWorkday​(Date xDate,
                                       int xMode)
        returns the date of the next workday
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • NextWorkdayName

        public static String NextWorkdayName​(Date xDate,
                                             int xMode,
                                             boolean Shortname)
        returns the name of the next workday
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • NextYear

        public static int NextYear​(Date xDate)
        returns the next year
      • Now

        public static Date Now()
        returns the current date
      • NthWeekday

        public static Date NthWeekday​(Date xDate,
                                      int xNth,
                                      int xWeekday,
                                      boolean xMode)
        returns the date subsequent to the weekday setted for the number of recurrences specified
        Parameters:
        xDate - the start date
        xNth - the number of recurrences
        xWeekday - the weekday (1 = sunday, 2 = monday, ..., 7 = saturday)
        xMode - [false] = starts from the day specified in the date, [true] = starts from the first day of the month shown in the date
      • PreviousDate

        public static Date PreviousDate​(Date xDate)
        returns the previous date (24 hours before), 'Null' is date not valid or error
      • PreviousDay

        public static int PreviousDay​(Date xDate)
        returns the previous day
      • PreviousMonth

        public static int PreviousMonth​(Date xDate)
        returns the previous month
      • PreviousMonthName

        public static String PreviousMonthName​(Date xDate,
                                               boolean xShortname)
        returns the previous month name
      • PreviousWeekday

        public static int PreviousWeekday​(Date xDate)
        returns the previous weekday (1 = sunday, 2 = monday, ..., 7 = saturday)
      • PreviousWeekdayName

        public static String PreviousWeekdayName​(Date xDate,
                                                 boolean xShortname)
        returns the day name of the previous weekday
      • PreviousWorkday

        public static Date PreviousWorkday​(Date xDate,
                                           int xMode)
        returns the date of the previous workday
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • PreviousWorkdayName

        public static String PreviousWorkdayName​(Date xDate,
                                                 int xMode,
                                                 boolean Shortname)
        returns the name of the previous workday
        Parameters:
        xDate - the start date
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • PreviousYear

        public static int PreviousYear​(Date xDate)
        returns the previous year
      • SetDateFormat

        public static void SetDateFormat​(String xDateFormat)
        sets the date format
        Parameters:
        xDateFormat - the date format
      • SetFirstWeekday

        public static void SetFirstWeekday​(int xWeekday)
        sets the first weekday
        Parameters:
        xWeekday - the weekday (1 = sunday , 2 = monday, ..., 7 = saturday)
      • SkipDateIfHolidaysOrWeekend

        public static Date SkipDateIfHolidaysOrWeekend​(Date xDate,
                                                       boolean xForward)
        returns the first date after the holidays and/or weekend
      • SkipDateIfHolidays

        public static Date SkipDateIfHolidays​(Date xDate,
                                              boolean xForward)
        returns the first date after the holidays
      • SkipDateIfWeekend

        public static Date SkipDateIfWeekend​(Date xDate,
                                             boolean xForward)
        returns the first date after the weekend
      • Weekday

        public static int Weekday​(Date xDate)
        returns the the weekday (1 = sunday, 2 = monday, ..., 7 = saturday)
      • WeekdayName

        public static String WeekdayName​(Date xDate,
                                         boolean xShortname)
        returns the day name of the weekday
      • Year

        public static int Year​(Date xDate)
        returns the year