Class DateFunctions
java.lang.Object
com.scriptbasic.utility.functions.DateFunctions
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic LocalDateConversion function to datestatic LocalDatedate()static LocalDateReturns a date containing a date to which a specified time interval has been added.static longReturns a Variant (Long) specifying the number of time intervals between two specified dates.static BasicDateValuedateserial(Integer year, Integer month, Integer dayOfMonth) Returns a Date for a specified year, month, and day.static IntegerReturns a Integer specifying a whole number between 1 and 31, inclusive, representing the day of the month.static DateFunctions.DateFormatterstatic DateFunctions.DateParserstatic booleanstatic StringisoDateFormatter(LocalDate localDate) Obtains an instance of LocalDate from a text string such as 2007-12-03.static LocalDateisoDateParser(String src) Basic implementation of date parser Obtains an instance of LocalDate from a text string such as 2007-12-03.static IntegerReturns a Integer specifying a whole number between 1 and 12, inclusive, representing the month of the year.static voidsetDateFormatter(DateFunctions.DateFormatter formatter) static voidstatic IntegerReturns a Integer containing a whole number representing the year.
-
Field Details
-
DATE_ZERO
Date zero is 30.12.1899 Due to compatibility with MS VBA
-
-
Constructor Details
-
DateFunctions
public DateFunctions()
-
-
Method Details
-
setDateParser
-
getDateParser
-
setDateFormatter
-
getDateFormatter
-
cdate
Conversion function to date- Parameters:
o- date compatible object- Returns:
- date
- Throws:
BasicRuntimeException- failed to convert to date
-
date
-
year
Returns a Integer containing a whole number representing the year.- Parameters:
operand- value representing date (numeric, string, date)- Returns:
- whole number representing the year
- Throws:
ScriptBasicException- if operand is not date
-
month
Returns a Integer specifying a whole number between 1 and 12, inclusive, representing the month of the year.- Parameters:
operand- value representing date (numeric, string, date)- Returns:
- month, number between 1 and 12
- Throws:
ScriptBasicException- if operand is not date
-
day
Returns a Integer specifying a whole number between 1 and 31, inclusive, representing the day of the month.- Parameters:
operand- value representing date (numeric, string, date)- Returns:
- day of the month, number between 1 and 31
- Throws:
ScriptBasicException- if operand is not date
-
dateserial
public static BasicDateValue dateserial(Integer year, Integer month, Integer dayOfMonth) throws ScriptBasicException Returns a Date for a specified year, month, and day.- Parameters:
year- number between 100 and 9999month- the month-of-year to represent, from 1 (January) to 12 (December)dayOfMonth- the day-of-month to represent, from 1 to 31- Returns:
- date object
- Throws:
ScriptBasicException- error when parameter is out of range
-
dateadd
public static LocalDate dateadd(String interval, Long number, Object date) throws ScriptBasicException Returns a date containing a date to which a specified time interval has been added.- Parameters:
interval- String that is the interval of time you want to add.number- Number of intervals you want to add. It can be positive (to get dates in the future) or negative (to get dates in the past).date- Date or literal representing the date to which the interval is added.- Returns:
- date with added time interval
- Throws:
ScriptBasicException- when incorrect arguments
-
datediff
public static long datediff(String interval, LocalDate date1, LocalDate date2) throws ScriptBasicException Returns a Variant (Long) specifying the number of time intervals between two specified dates.- Parameters:
interval- Interval of time used to calculate the difference between date1 and date2.date1- Date used for calculationdate2- Date used for calculation- Returns:
- number of time intervals between two specified dates
- Throws:
ScriptBasicException- when unsupported type of interval
-
isoDateParser
Basic implementation of date parser Obtains an instance of LocalDate from a text string such as 2007-12-03.- Parameters:
src- date to be parsed- Returns:
- date
- Throws:
BasicRuntimeException- Exception if failed to parse date
-
isoDateFormatter
Obtains an instance of LocalDate from a text string such as 2007-12-03.- Parameters:
localDate- date to format- Returns:
- formatted date
-
isDate
-