public static interface DatamartContext.Calendar
Calendar
.
A TimeUnit can be
- DAY, named 'Day'
- WEEK, named 'Week'
- MONTH, named 'Month'
- QUARTER, named 'Quarter'
- YEAR, named 'Year'
(the name can be used in various helper methods accepting a string argument rather than the enumeration value).Modifier and Type | Method and Description |
---|---|
String |
add(String periodAsString,
int numberOfUnits,
String unitAsString)
Parses the a period string and offsets the start date of the resulting TimePeriod with a number of TimeUnits.
|
long |
getDaysDiff(String endPeriod,
String startPeriod)
Calculates the number of days between the start date of period1 and end date of period2 (both inclusive).
|
Date |
getEndDate(String period)
Returns the end date of given TimePeriod.
|
Date |
getStartDate(String period)
Returns the start date of given TimePeriod.
|
CalendarUtil.TimePeriod |
getTimePeriod(String periodAsString)
Returns the TimePeriod object matching its string representation.
|
CalendarUtil.TimePeriod |
getTimePeriodByDate(String dateAsString,
String unitAsString)
Parses a date, as well as a named TimeUnit, resulting in a TimePeriod with that unit
that encompasses the given date.
|
List<String> |
getTimePeriodNames(String startPeriodAsString,
String endPeriodAsString,
String unitAsString)
Useful for constructing Options lists (user entry/input parameters).
|
List<CalendarUtil.TimePeriod> |
getTimePeriods(Date startDate,
Date endDate,
CalendarUtil.TimeUnit unit) |
List<CalendarUtil.TimePeriod> |
getTimePeriods(String startPeriodAsString,
String endPeriodAsString,
String unitAsString)
Same as above but now returning a list of TimePeriod objects, rather than the corresponding period names.
|
Date |
parseDate(String dateAsString)
Not so much a PA specific helper method: best attempt at converting a string representation (not necessarily
in the 'yyyy-MM-dd' format) to a Date.
|
DateTime |
parseDateTime(String datetimeAsString)
Not so much a PA specific helper method: best attempt at converting a string representation (not necessarily
in the 'yyyy-MM-dd'T'HHmmss' format) to a DateTime.
|
Filter |
timePeriodAsFilter(CalendarUtil.TimePeriod timePeriod,
String dateDimFieldName)
Helper method to build a filter representing
dateDimFieldName in [timePeriod.startPeriod, timePeriod.endPeriod]
Note the inclusion on both ends; this is to accommodate the most frequent use case where the TimePeriod is a single period, for
example InvoiceDate in [2015,2015]. |
Filter timePeriodAsFilter(CalendarUtil.TimePeriod timePeriod, String dateDimFieldName)
dateDimFieldName in [timePeriod.startPeriod, timePeriod.endPeriod]
Note the inclusion on both ends; this is to accommodate the most frequent use case where the TimePeriod is a single period, for
example InvoiceDate in [2015,2015]. An example of a non-singular period filter is [2015-Q1, 2015-Q2]; see TimePerdiod
for more details.timePeriod
- The CalendarUtil.TimePeriod
that the dateDimFieldName
field needs to match.dateDimFieldName
- The Datamart field of type 'Date' to filter onFilter
limiting the given date field to the given time period.CalendarUtil.TimePeriod getTimePeriod(String periodAsString)
Filter
or DatamartContext.DataSlice
definition.periodAsString
- Textual representation of a TimePeriod, such as '2015', '2015-Q1' etc.CalendarUtil.TimePeriod getTimePeriodByDate(String dateAsString, String unitAsString)
dateAsString
- A 'yyyy-MM-dd' string representation of Date
.unitAsString
- String representation of a TimeUnit.List<String> getTimePeriodNames(String startPeriodAsString, String endPeriodAsString, String unitAsString)
startPeriodAsString
- String representation of the start TimePeriod.endPeriodAsString
- String representation of the end TimePeriod.unitAsString
- String representation of a TimeUnit.List<CalendarUtil.TimePeriod> getTimePeriods(String startPeriodAsString, String endPeriodAsString, String unitAsString)
startPeriodAsString
- endPeriodAsString
- unitAsString
- List<CalendarUtil.TimePeriod> getTimePeriods(Date startDate, Date endDate, CalendarUtil.TimeUnit unit)
Date getStartDate(String period)
period
- String representation of a TimePeriod.Date getEndDate(String period)
period
- String representation of a TimePeriod.String add(String periodAsString, int numberOfUnits, String unitAsString)
periodAsString
- String representation of the end TimePeriod.numberOfUnits
- The Number of TimeUnit to use as the offset.unitAsString
- String representation of a TimeUnit.long getDaysDiff(String endPeriod, String startPeriod)
endPeriod
- String representation of the end TimePeriod.startPeriod
- String representation of the start TimePeriod.Date parseDate(String dateAsString)
dateAsString
- String representation of a Date.null
if no match.DateTime parseDateTime(String datetimeAsString)
dateAsString
- String representation of a DateTime.DateTime
or null
if no match.Copyright © 2019. All rights reserved.