public interface DateTimeUtils
"MMM dd',' yyyy '-' HH:mm:ss z"
Short Datetime: "MM/dd/yy KK:mm a"
- Server's default timezone
Long Date: "MMM dd',' yyyy"
Short Date: "MM/dd/yy"
Short Time 1: "HH:mm:ss z"
Short Time 2: "KK:mm:ss a"
- Server's default timezone
Timestamp: "HHmmss"
- always considered to be in GMT
The 'Standard Pega ISO Date', Pega TimeStamp or datetimestamp is referred to here
and elsewhere and is the format used for internal storage of dates and times within
PegaRULES.
The java.util.Date formatting pattern looks like this:
"yyyyMMdd'T'HHmmss.SSS 'GMT'"
Legend for all these time format strings:
yyyy
is the string containing 4 digit year.
MM
is the string containing a 2 digit month, valid values are 01..12
dd
is the string containing a 2 digit day, valid values are 01..31 (with the usual constraints.)
HH
is the string containing a 2 digit hour, valid values are 00..23.
KK
is the string containing a 2 digit hour, valid values are 00..11 (has am/pm).
mm
is the string containing a 2 digit minute, valid values are 00..59
ss
is the string containing a 2 digit second, valid values are 00..59
sss
is the string containing a 3 digit millisecond, valid values are 000..999
a
is the placeholder for the AM/PM indicator - hour always coded with KK.
GMT
is constant and indicates that the timestamp is always stored
as a Greenwich Mean Time.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT |
static java.lang.String |
VERSION |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
addMonthsToSameDay(java.lang.String theDate,
int numOfMonths)
This function will return a date
numOfMonths from the specified date,
where the day of the week and week of the month are the same. |
java.lang.String |
addToDate(java.lang.String theDate,
java.lang.String days,
java.lang.String hours,
java.lang.String minutes,
java.lang.String seconds)
This function will add days, hours,minutes,seconds to the time passed in and will return an ISO time to the caller.
|
java.lang.String |
currentDate(java.lang.String strDateFormat,
java.lang.String strTimeZone)
Return Today's Date -
Keep track of system starts
|
long |
currentTimeUnique()
return a long that is unique within this PegaRULES jvm/instance
by incrementing a counter while currentTimeMillis remains constant
|
double |
dateTimeDifference(java.lang.String strBeginTime,
java.lang.String strEndTime,
java.lang.String strPrecision)
Computes the difference between two Pega standard internal (ISO) format dates with
the result being corrected for the specified precision.
|
java.lang.String |
dateTimeDuration(java.lang.String strBeginTime,
java.lang.String strEndTime,
java.lang.String strPrecision)
compute the difference between two dates (passed as strings)
|
java.lang.String |
formatDateStamp(java.util.Date aDate)
Format the specified date as a PegaRULES date stamp (yyyyMMdd)
|
java.lang.String |
formatDateTime(java.lang.String strDateTime,
java.lang.String strPattern,
java.lang.String strTimeZone,
java.lang.String strLocale)
(re)format a date/time string using the specified parameters
|
java.lang.String |
formatDateTime(java.lang.String strDateTime,
java.lang.String strPattern,
java.lang.String strTimeZone,
java.lang.String strLocale,
boolean boolSupport24hr)
(re)format a date/time string using the specified parameters
|
java.lang.String |
formatDateTimeStamp(java.util.Date aDateTime)
Format the specified time as a PegaRULES time stamp (ISO format, GMT zone)
|
java.lang.String |
formatTimeOnlyStamp(java.util.Date aTime)
Format the specified Time as a PegaRULES Time stamp (HHmmss [assumed GMT])
|
java.lang.String |
formatTimeStamp(java.util.Date aTime)
Format the specified Time as a PegaRULES Date Time stamp (ISO format, GMT zone)
Note that this method returns a date/time, not a time, for backward compatibility purposes.
|
java.lang.String |
getCurrentTimeStamp()
Returns the current date and time as a PegaRULES time stamp (ISO format, GMT zone)
|
java.util.Date |
getDate(java.lang.String strZeusDateTime)
Coverts an internal date time stamp into a Java Date object.
|
long |
parseDateString(java.lang.String strDate)
Attempts to interpret the string s as a representation
of a date and time.
|
java.util.Date |
parseDateTimeStamp(java.lang.String strDateTime)
Converts string form of datetimestamp to a Date object.
|
java.util.Date |
parseDateTimeString(java.lang.String strDateTime)
Converts string containing various formats of date & datetime into a Date object.
|
java.util.Date |
parseTimeOfDayString(java.lang.String aTime)
Converts string form of timestamp to a Date object.
|
java.lang.String |
timeDifference(java.lang.String strStart,
int nDays,
int nHours,
int nMinutes,
int nSeconds)
adds an interval to the specified time, using "business day" logic
see TimeDifferenceBusinessDays
uses the server's default calendar and GMT time zone
|
java.lang.String |
timeDifferenceBusinessDays(java.util.Calendar aCalendar,
java.lang.String strStart,
int nDays,
int nHours,
int nMinutes,
int nSeconds)
adds an interval to the specified time, using "business day" logic
assumes US business day rules (Saturday/Sunday closed), ignores
possibility of holidays (constant 5 day weeks).
|
java.lang.String |
timeDifferenceFirstBusinessDay(java.util.Calendar aCalendar,
java.lang.String strStart)
returns the first business day after the specified date, using "business day" logic
assumes US business day rules (Saturday/Sunday closed), ignores
possibility of holidays (constant 5 day weeks).
|
static final java.lang.String VERSION
static final java.lang.String COPYRIGHT
java.lang.String addToDate(java.lang.String theDate, java.lang.String days, java.lang.String hours, java.lang.String minutes, java.lang.String seconds)
theDate
- base date to start withdays
- to add to base datehours
- to add to base dateminutes
- to add to base dateseconds
- to add to base datejava.lang.String currentDate(java.lang.String strDateFormat, java.lang.String strTimeZone)
strDateFormat
- format string to use for creating the datestrTimeZone
- Time Zone namelong currentTimeUnique()
double dateTimeDifference(java.lang.String strBeginTime, java.lang.String strEndTime, java.lang.String strPrecision)
strBeginTime
- Start date formatted in standard internal form.strEndTime
- Ending date formatted in standard internal form.strPrecision
- Units the result is to be interpreted with:
java.util.Date parseTimeOfDayString(java.lang.String aTime)
aTime
- PegaRULES standard timestamp string (HHmmss)java.util.Date getDate(java.lang.String strZeusDateTime)
strZeusDateTime
- java.lang.String getCurrentTimeStamp()
java.lang.String addMonthsToSameDay(java.lang.String theDate, int numOfMonths)
numOfMonths
from the specified date,
where the day of the week and week of the month are the same.
For example, the gregorian date May 1, 2004 is the first Saturday of the month. Adding 1 month to that will return June 5, 2004, which is also the first Saturday of the month.
theDate
- base date to start withnumOfMonths
- number of months to add to that datejava.lang.String dateTimeDuration(java.lang.String strBeginTime, java.lang.String strEndTime, java.lang.String strPrecision)
strBeginTime
- starting timestrEndTime
- ending timestrPrecision
- desired precision, one of "CYMDhmsS" to specify
century, year, month, hour, minute, second, or millisecond respectivelylong parseDateString(java.lang.String strDate)
It accepts many syntaxes; in particular, it recognizes the IETF standard date syntax: "Sat, 12 Aug 1995 13:30:00 GMT". It also understands the continental U.S. time-zone abbreviations, but for general use, a time-zone offset should be used: "Sat, 12 Aug 1995 13:30:00 GMT+0430" (4 hours, 30 minutes west of the Greenwich meridian). If no time zone is specified, the local time zone is assumed. GMT and UTC are considered equivalent.
The string s is processed from left to right, looking for data of interest. Any material in s that is within the ASCII parenthesis characters ( and ) is ignored. Parentheses may be nested. Otherwise, the only characters permitted within s are these ASCII characters:
and whitespace characters.abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789,+-:/
A consecutive sequence of decimal digits is treated as a decimal number:
SimpleDateFormat
.
A consecutive sequence of letters is regarded as a word and treated as follows:
Once the entire string s has been scanned, it is converted to a time result in one of two ways. If a time zone or time-zone offset has been recognized, then the year, month, day of month, hour, minute, and second are interpreted in UTC and then the time-zone offset is applied. Otherwise, the year, month, day of month, hour, minute, and second are interpreted in the local time zone.
strDate
- a string to be parsed as a date.officially deprecated As of JDK version 1.1,
replaced by DateFormat.parse(String s)
.
java.util.Date parseDateTimeStamp(java.lang.String strDateTime)
strDateTime
- PegaRULES standard date/time stringjava.util.Date parseDateTimeString(java.lang.String strDateTime)
strDateTime
- The various supported input date formats.java.lang.String formatDateTime(java.lang.String strDateTime, java.lang.String strPattern, java.lang.String strTimeZone, java.lang.String strLocale)
strDateTime
- input time stringstrPattern
- (unused)strTimeZone
- timezone for output string,
if null, the server's default is usedstrLocale
- locale to use for formatting,
if null, the server's default is usedjava.lang.String formatDateTime(java.lang.String strDateTime, java.lang.String strPattern, java.lang.String strTimeZone, java.lang.String strLocale, boolean boolSupport24hr)
strDateTime
- input time stringstrPattern
- (unused)strTimeZone
- timezone for output string,
if null, the server's default is usedstrLocale
- locale to use for formatting,
if null, the server's default is usedboolSupport24hr
- java.lang.String formatDateTimeStamp(java.util.Date aDateTime)
aDateTime
- Date objectjava.lang.String formatDateStamp(java.util.Date aDate)
aDate
- Date objectjava.lang.String formatTimeStamp(java.util.Date aTime)
aTime
- objectjava.lang.String formatTimeOnlyStamp(java.util.Date aTime)
aTime
- objectjava.lang.String timeDifference(java.lang.String strStart, int nDays, int nHours, int nMinutes, int nSeconds)
strStart
- base date/time,
if null or zero length, uses the current date and timenDays
- number of days to addnHours
- number of hours to addnMinutes
- number of minutes to addnSeconds
- number of seconds to addjava.lang.String timeDifferenceBusinessDays(java.util.Calendar aCalendar, java.lang.String strStart, int nDays, int nHours, int nMinutes, int nSeconds)
aCalendar
- calendar to be used for computation,
if null, uses the server's default calendar and local time zonestrStart
- base date/time,
if null or zero length, uses the current date and timenDays
- number of days to addnHours
- number of hours to addnMinutes
- number of minutes to addnSeconds
- number of seconds to addjava.lang.String timeDifferenceFirstBusinessDay(java.util.Calendar aCalendar, java.lang.String strStart)
aCalendar
- calendar to be used for computation,
if null, uses the server's default calendar and GMT time zonestrStart
- base date/time,
if null or zero length, uses the current date and timeCopyright © 2015 Pegasystems Inc. All Rights Reserved.