pdk.util.Date
functions to operate with dates
Functions
addDays
Adds or subtracts the specified amount of days to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
days :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or days argument is
NULL
addHours
Adds or subtracts the specified amount of hours to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
hours :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or hours argument is
NULL
addMilliseconds
Adds or subtracts the specified amount of milliseconds to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
milliseconds :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or milliseconds argument is
NULL
addMinutes
Adds or subtracts the specified amount of minutes to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
minutes :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or minutes argument is
NULL
addMonths
Adds or subtracts the specified amount of months to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
months :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or months argument is
NULL
addSeconds
Adds or subtracts the specified amount of seconds to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
seconds :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or seconds argument is
NULL
addWeeks
Adds or subtracts the specified amount of weeks to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
weeks :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or weeks argument is
NULL
addYears
Adds or subtracts the specified amount of years to the date object, based on the calendar's rules.
Arguments:
date :: pdk.core.Date
years :: pdk.core.Integer
Result:
output :: pdk.core.Date - new date object
Possible exceptions
NullPointerException - throws if the date or years argument is
NULL
after
Returns whether the first argument represents a time after the time represented by the second argument.
Arguments:
date1 :: pdk.core.Date
date2 :: pdk.core.Date
Result:
output :: pdk.core.Boolean - true if the time of the first argument is after the time represented by the second argument; false otherwise.
Possible exceptions
NullPointerException - throws if the date1 or date2 argument is
NULL
before
Returns whether the first argument represents a time before the time represented by the second argument.
Arguments:
date1 :: pdk.core.Date
date2 :: pdk.core.Date
Result:
output :: pdk.core.Boolean - true if the time of the first argument is before the time represented by the second argument; false otherwise.
Possible exceptions
NullPointerException - throws if the date1 or date2 argument is
NULL
currentDate
Returns a Date object representing the current time value (UTC).
Arguments:
no
Result:
output :: pdk.core.Date - a Date representing the time value.
difference
Returns the difference between two dates by specified field. If the difference is more then N and less then N+1, then N is a result. For example, if you had the date of 25 May 2020 12:34:56.345 and 27 May 2020 16:10:12.300, if you passed with 3 (Day), it would return 2. If this was passed with 1 (Year), it would return 0. Fields indicators:
Field indicator | Value |
---|---|
Year | 1 |
Month | 2 |
Day | 3 |
Hour | 4 |
Minute | 5 |
Second | 6 |
Arguments:
date1 :: pdk.core.Date
date2 :: pdk.core.Date
field :: pdk.core.Integer
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date1, date2 or field argument is
NULL
getDaysCountInMonth
Returns the amount of days for specified year and month.
Arguments:
year :: pdk.core.Integer
month :: pdk.core.Integer
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the year or month argument is
NULL
getDaysCountInYear
Returns the amount of days for specified yer.
Arguments:
year :: pdk.core.Integer
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the year or month argument is
NULL
getDayOfYear
Returns the value that indicates the day number within the data year.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getDayOfMonth
Returns the value that indicates the day number within the data month.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getDayOfWeek
Returns the value that indicates the day number within the data week.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getFirstDayOfMonth
Returns the first day of the specified month.
Day | Value |
---|---|
Sunday | 1 |
Monday | 2 |
Tuesday | 3 |
Wednesday | 4 |
Thursday | 5 |
Friday | 6 |
Saturday | 7 |
Arguments:
year :: pdk.core.Integer
month :: pdk.core.Integer
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the year or month argument is
NULL
getFirstDayOfYear
Returns the first day of the specified year
Day | Value |
---|---|
Sunday | 1 |
Monday | 2 |
Tuesday | 3 |
Wednesday | 4 |
Thursday | 5 |
Friday | 6 |
Saturday | 7 |
Arguments:
year :: pdk.core.Integer
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the year or month argument is
NULL
getHour
Returns the value that indicates the hour of the morning or afternoon. NOTE value is in 12 hours format.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getHourOfDay
Returns the value that indicates the hour of the day.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getMillisecond
Returns the value that indicates the millisecond within the second.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getMinute
Returns the value that indicates the minute within the hour.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getMonth
Returns the value that indicates the month within the year.
The value returned is between 1
and 12
, with the value 1
representing January.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getSecond
Returns the value that indicates the second within the minute.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getTimeInMills
The currently set time for the argument date, expressed in milliseconds after January 1, 1970, 0:00:00 GMT.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getWeekOfMonth
Returns the value that indicates the week number within the argument date month.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getWeekOfYear
Returns the value that indicates the week number within the argument date year.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
getYear
Returns the value that indicates the argument year.
Arguments:
date :: pdk.core.Date
Result:
output :: pdk.core.Integer
Possible exceptions
NullPointerException - throws if the date argument is
NULL
fromString
Parses text from the beginning of the given string to produce a date. Arguments:
String - the string to be converted.
String - the format of the date represented by the string.
Format examples:
Date and Time Pattern | Result |
---|---|
"yyyy-MM-dd" | 2001-07-04T00:00:00Z |
"yyyy-MM-dd'T'HH:mm:ss" | 2001-07-04T12:08:56 |
Arguments:
date :: pdk.core.String - the string to be converted.
format :: pdk.core.String - the format of the date represented by the string.
Result:
output :: pdk.core.Date - new date object.
Possible exceptions
NullPointerException - throws if the date or format argument is
NULL
isSameDay
Checks if two date objects are on the same day ignoring time. 05 May 2020 11:00 and 05 May 2020 23:45 would return true. 05 May 2020 11:00 and 10 May 2020 14:30 would return false.
Arguments:
date1 :: pdk.core.Date
date2 :: pdk.core.Date
Result:
output :: pdk.core.Boolean - true if they represent the same day.
Possible exceptions
NullPointerException - throws if the date1 or date2 argument is
NULL
truncate
Truncates a date, leaving the field specified as the most significant field. For example, if you had the date-time of 05 May 2020 12:34:56.345, if you passed with 4 (Hour), it would return 05 May 2020 12:00:00.000. If this was passed with 2 (Month), it would return 1 May 2020 0:00:00.000.
Field indicator | Value |
---|---|
Year | 1 |
Month | 2 |
Day | 3 |
Hour | 4 |
Minute | 5 |
Second | 6 |
Arguments:
date :: pdk.core.Date
field :: pdk.core.Integer
Result:
output :: pdk.core.Date - the truncated date.
Possible exceptions
NullPointerException - throws if the date or field argument is
NULL
round
Rounds a date, leaving the field specified as the most significant field. For example, if you had the date-time of 25 May 2020 12:34:56.345, if you passed with 4 (Hour), it would return 05 May 2020 13:00:00.000. If this was passed with 2 (Month), it would return 1 August 2020 0:00:00.000.
Field indicator | Value |
---|---|
Year | 1 |
Month | 2 |
Day | 3 |
Hour | 4 |
Minute | 5 |
Second | 6 |
Arguments:
date :: pdk.core.Date
field :: pdk.core.Integer
Result:
output :: pdk.core.Date - the rounded date.
Possible exceptions
NullPointerException - throws if the date or field argument is
NULL
Last updated