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