Class fDATESTRING


  • public class fDATESTRING
    extends Object
    datestring functions
    • Constructor Detail

      • fDATESTRING

        public fDATESTRING()
    • Method Detail

      • AddDaysToDate

        public static String AddDaysToDate​(String xDatestring,
                                           int xDays)
        returns the datestring on which have added days
        Parameters:
        xDatestring - the datestring to which should be added the days
        xDays - the number of days to add to the datestring
      • 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 String AddMonthsToDate​(String xDatestring,
                                             int xMonths)
        returns the datestring on which have added months
        Parameters:
        xDatestring - the datestring to which should be added the months
        xMonths - the number of months to add to the datestring
      • AddYearsToDate

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

        public static int Age​(String xBirthDatestring)
        returns the age (years) from the birthdate
      • CountHolidaysFromDates

        public static int CountHolidaysFromDates​(String xStartDatestring,
                                                 String xEndDatestring)
        returns the number of holidays between two datestring
        Parameters:
        xStartDatestring - the start datestring
        xEndDatestring - the end datestring
      • CountWeekdayInMonth

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

        public static int CountWorkdaysFromDates​(String xStartDatestring,
                                                 String xEndDatestring,
                                                 int xMode)
        returns the number of working days between two datestring
        Parameters:
        xStartDatestring - the start datestring
        xEndDatestring - the end datestring
        xMode - 0 = normal, 1 = keep holidays, 2 = keep weekends, 3 = keep holidays and weekends
      • DateDiff

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

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

        public static String DateFromYMDHMS​(int year,
                                            int month,
                                            int day,
                                            int hour,
                                            int minute,
                                            int second)
        returns the datestring corresponding to the settings of the year, month, day, hour, minute and second
      • DateConversion

        public static String DateConversion​(String xDateString,
                                            int xDateInputType,
                                            int xDateOutputType,
                                            String xSeparator)
        returns a datestring converted as required
        Parameters:
        xDatastring - the datestring to be converted
        xDateInputType - the datestring format input
        xDateOutputType - the datestring format output
        xSeparator - the separator to be applied to the converted datestring the date format in input or output can be: 1 = "DD/MM/YYYY" 2 = "MM/DD/YYYY" 3 = "YYYY/MM/DD") 4 = "YYYY/DD/MM") 5 = "DD/YYYY/MM") 6 = "MM/YYYY/DD") 7 = "DDMMYYYY" 8 = "MMDDYYYY" 9 = "YYYYMMDD") 10 = "YYYYDDMM") 11 = "DDYYYYMM") 12 = "MMYYYYDD") returns the converted datestring
      • 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 datestring 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​(String xDatestring)
        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 String EasterDate​(int xYear)
        returns the easter datestring
      • FindDateNextWeekday

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

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

        public static String FirstDateOfMonth​(String xDatestring)
        returns the datestring of the first day of the month
      • FirstDateOfQuarter

        public static String FirstDateOfQuarter​(String xDatestring)
        returns the datestring corresponding to the first day of a quarter
      • FirstDateOfWeek

        public static String FirstDateOfWeek​(String xDatestring)
        returns the datestring of the first day of the week
      • FirstDateOfYearWeek

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

        public static String FirstDateOfCurrentWeek()
        returns the datestring of the first day of the current week
      • FirstWorkdayOfMonth

        public static String FirstWorkdayOfMonth​(String xDatestring,
                                                 int xMode)
        returns the datestring of the first workday of the month
        Parameters:
        xDatestring - the start datestring
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • FirstWorkdayNameOfMonth

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

        public static String GetDateFormat()
        returns the datestring 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
      • InsertNewHolidayInMemory

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

        public static boolean IsDate​(String xDatestring)
        returns [true] if the datestring is valid, otherwise [false]
        Parameters:
        xDatestring - the datestring 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​(String xDatestring)
        returns [true] if the datestring is a holiday, otherwise [false]
      • IsWeekend

        public static boolean IsWeekend​(String xDatestring)
        returns [true] if the datestring is a weekend, otherwise it returns [false]
      • LastDateOfMonth

        public static String LastDateOfMonth​(String xDatestring)
        returns the datestring of the last day of the month
      • LastDateOfQuarter

        public static String LastDateOfQuarter​(String xDatestring)
        returns the datestring corresponding to the last day of a quarter
      • LastDateOfWeek

        public static String LastDateOfWeek​(String xDatestring)
        returns the datestring corresponding to the last day of the week
      • LastDayOfMonth

        public static int LastDayOfMonth​(String xDatestring)
        returns the last day of the month
      • LastWorkdayOfMonth

        public static String LastWorkdayOfMonth​(String xDatestring,
                                                int xMode)
        returns the datestring of the last workday of the month
        Parameters:
        xDatestring - the start datestring
        xMode - = 0 skip holidays, = 1 skip weekends, = 2 skip holidays and weekends
      • LastWorkdayNameOfMonth

        public static String LastWorkdayNameOfMonth​(String xDatestring,
                                                    int xMode,
                                                    boolean Shortname)
        returns the name of the last workday of the month
        Parameters:
        xDatestring - the start datestring
        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​(String xDatestring)
        returns the month
      • MonthName

        public static String MonthName​(String xDatestring,
                                       boolean xShortname)
        returns the month name
      • NextAnniversary

        public static String NextAnniversary​(String xDatestring)
        returns the datestring of the next anniversary
      • NextDate

        public static String NextDate​(String xDatestring)
        returns the next datestring (24 hours later), 'Null' is datestring not valid or error
      • NextDay

        public static int NextDay​(String xDatestring)
        returns the day next
      • NextMonth

        public static int NextMonth​(String xDatestring)
        returns the next month
      • NextMonthName

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

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

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

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

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

        public static int NextYear​(String xDatestring)
        returns the next year
      • Now

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

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

        public static String PreviousDate​(String xDatestring)
        returns the previous datestring (24 hours before), 'Null' is datestring not valid or error
      • PreviousDay

        public static int PreviousDay​(String xDatestring)
        returns the previous day
      • PreviousMonth

        public static int PreviousMonth​(String xDatestring)
        returns the previous month
      • PreviousMonthName

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

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

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

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

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

        public static int PreviousYear​(String xDatestring)
        returns the previous year
      • SetDateFormat

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

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

        public static String SkipDateIfHolidays​(String xDatestring,
                                                boolean xForward)
        returns the first datestring after the holidays
      • SkipDateIfHolidaysOrWeekend

        public static String SkipDateIfHolidaysOrWeekend​(String xDatestring,
                                                         boolean xForward)
        returns the first datestring after the holidays and/or weekend
      • SkipDateIfWeekend

        public static String SkipDateIfWeekend​(String xDatestring,
                                               boolean xForward)
        returns the first datestring after the weekend
      • Weekday

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

        public static String WeekdayName​(String xDatestring,
                                         boolean xShortname)
        returns the day name of the week
      • Year

        public static int Year​(String xDatestring)
        returns the year