Package db2000.J.eXtrafunctions
Class fDATE
- java.lang.Object
-
- db2000.J.eXtrafunctions.fDATE
-
public class fDATE extends Object
date functions
-
-
Constructor Summary
Constructors Constructor Description fDATE()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Date
AddDaysToDate(Date xDate, int xDays)
returns the date on which have added daysstatic boolean
AddEasterDayInHolidays(int xYear, boolean xAddEasterMonday)
inserts easter days in holidays returns [true] if the upload was successful, otherwise [false]static Date
AddMonthsToDate(Date xDate, int xMonths)
returns the date on which have added monthsstatic Date
AddYearsToDate(Date xDate, int xYears)
returns the date on which have added yearsstatic int
Age(Date xBirthDate)
returns the age (years) from the birthdatestatic int
CountHolidaysFromDates(Date xStartDate, Date xEndDate)
returns the number of holidays between two datesstatic int
CountWeekdayInMonth(int xWeekday, Date xDate)
returns the number of times the weekday of the monthstatic int
CountWorkdaysFromDates(Date xStartDate, Date xEndDate, int xMode)
returns the number of working days between two datesstatic long
DateDiff(Date xDate1, Date xDate2, String xInterval, boolean xAbsoluteValue)
returns a value corresponding to the number of time intervals between two datesstatic Date
DateFromYMD(int year, int month, int day)
returns the date corresponding to the settings of the year, month and daystatic 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 secondstatic Date
DatestringToDate(String xDateString)
converts a datestring to a datestatic String
DateToDatestring(Date xDate)
converts a date to a datestringstatic int
Day(Date xDate)
returns the day of the monthstatic int
DaysInMonth(int xYear, int xMonth)
returns the days number of the monthstatic Date
EasterDate(int xYear)
returns the easter datestatic Date
FindDateNextWeekday(int xWeekday, Date xDate)
returns the date found of the next weekdaystatic Date
FindDatePreviousWeekday(int xWeekday, Date xDate)
returns the date found of the previous weekdaystatic Date
FirstDateOfCurrentWeek()
returns the date of the first day of the current weekstatic Date
FirstDateOfMonth(Date xDate)
returns the date of the first day of the monthstatic Date
FirstDateOfQuarter(Date xDate)
returns the date corresponding to the first day of a quarterstatic Date
FirstDateOfWeek(Date xDate)
returns the date of the first day of the weekstatic Date
FirstDateOfYearWeek(int xWeek, int xYear)
returns the date on the first day of the 'n' year week (0-51)static String
FirstWorkdayNameOfMonth(Date xDate, int xMode, boolean Shortname)
returns the name of the first workday of the monthstatic Date
FirstWorkdayOfMonth(Date xDate, int xMode)
returns the date of the first workday of the monthstatic String
GetDateFormat()
returns the date format in use (default is "dd/MM/yyyy")static int
GetFirstWeekday()
returns the first weekday (1 = sunday *default*, 2 = monday, ..., 7 = saturday)static String[]
GetHolidays()
returns an string array containing all holidays allocated in memory (item format = "MMDD")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]static boolean
IsDate(Date xDate)
returns [true] if the date is valid, otherwise [false]static boolean
IsDatestring(String xDatestring)
returns [true] if the datestring is valid, otherwise [false]static boolean
IsHoliday(Date xDate)
returns [true] if the date is a holiday, otherwise [false]static boolean
IsWeekend(Date xDate)
returns [true] if the date is a weekend, otherwise it returns [false]static Date
LastDateOfMonth(Date xDate)
returns the date of the last day of the monthstatic Date
LastDateOfQuarter(Date xDate)
returns the date corresponding to the last day of a quarterstatic Date
LastDateOfWeek(Date xDate)
returns the date corresponding to the last day of the weekstatic int
LastDayOfMonth(Date xDate)
returns the last day of the monthstatic String
LastWorkdayNameOfMonth(Date xDate, int xMode, boolean Shortname)
returns the name of the last workday of the monthstatic Date
LastWorkdayOfMonth(Date xDate, int xMode)
returns the date of the last workday of the monthstatic 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]static int
Month(Date xDate)
returns the month of the datestatic String
MonthName(Date xDate, boolean xShortname)
returns the month name of the datestatic Date
NextAnniversary(Date xDate)
returns the date of the next anniversarystatic Date
NextDate(Date xDate)
returns the next date (24 hours later), 'Null' is date not valid or errorstatic int
NextDay(Date xDate)
returns the next daystatic int
NextMonth(Date xDate)
returns the next monthstatic String
NextMonthName(Date xDate, boolean xShortname)
returns the next month namestatic int
NextWeekday(Date xDate)
returns the next weekday (1 = sunday, 2 = monday, ..., 7 = saturday)static String
NextWeekdayName(Date xDate, boolean xShortname)
returns the day name of the next weekdaystatic Date
NextWorkday(Date xDate, int xMode)
returns the date of the next workdaystatic String
NextWorkdayName(Date xDate, int xMode, boolean Shortname)
returns the name of the next workdaystatic int
NextYear(Date xDate)
returns the next yearstatic Date
Now()
returns the current datestatic Date
NthWeekday(Date xDate, int xNth, int xWeekday, boolean xMode)
returns the date subsequent to the weekday setted for the number of recurrences specifiedstatic Date
PreviousDate(Date xDate)
returns the previous date (24 hours before), 'Null' is date not valid or errorstatic int
PreviousDay(Date xDate)
returns the previous daystatic int
PreviousMonth(Date xDate)
returns the previous monthstatic String
PreviousMonthName(Date xDate, boolean xShortname)
returns the previous month namestatic int
PreviousWeekday(Date xDate)
returns the previous weekday (1 = sunday, 2 = monday, ..., 7 = saturday)static String
PreviousWeekdayName(Date xDate, boolean xShortname)
returns the day name of the previous weekdaystatic Date
PreviousWorkday(Date xDate, int xMode)
returns the date of the previous workdaystatic String
PreviousWorkdayName(Date xDate, int xMode, boolean Shortname)
returns the name of the previous workdaystatic int
PreviousYear(Date xDate)
returns the previous yearstatic void
SetDateFormat(String xDateFormat)
sets the date formatstatic void
SetFirstWeekday(int xWeekday)
sets the first weekdaystatic Date
SkipDateIfHolidays(Date xDate, boolean xForward)
returns the first date after the holidaysstatic Date
SkipDateIfHolidaysOrWeekend(Date xDate, boolean xForward)
returns the first date after the holidays and/or weekendstatic Date
SkipDateIfWeekend(Date xDate, boolean xForward)
returns the first date after the weekendstatic int
Weekday(Date xDate)
returns the the weekday (1 = sunday, 2 = monday, ..., 7 = saturday)static String
WeekdayName(Date xDate, boolean xShortname)
returns the day name of the weekdaystatic int
Year(Date xDate)
returns the year
-
-
-
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 daysxDays
- 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 monthsxMonths
- 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 yearsxYears
- 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 datexEndDate
- 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 = saturdayxDate
- 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 datexEndDate
- the end datexMode
- 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 1xDate2
- the date 2xInterval
- "y" = years, "m" = months, "d" days, "h" = hours, "n" = minutes, "s" = seconds, "!" = millisecondsxAbsoluteValue
- '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 datexMode
- = 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 datexMode
- = 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 datexMode
- = 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 datexMode
- = 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 datexMode
- = 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 datexMode
- = 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 datexNth
- the number of recurrencesxWeekday
- 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 datexMode
- = 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 datexMode
- = 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
-
-