Package com.xpn.xwiki.criteria.impl
Class PeriodFactory
- java.lang.Object
-
- com.xpn.xwiki.criteria.impl.PeriodFactory
-
public class PeriodFactory extends Object
Helper factory class for creating Period objects in velocity.
-
-
Constructor Summary
Constructors Constructor Description PeriodFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Period
createDayPeriod(long timestamp)
Creates a new Period instance that matches exactly the day that includes the specified time stamp.static Period
createDayPeriod(String date)
Creates a new Period instance that matches exactly the day that includes the specified date.static Period
createHourPeriod(long timestamp)
Creates a new Period instance that matches exactly the hour that includes the specified time stamp.static Period
createHourPeriod(String date)
Creates a new Period instance that matches exactly the hour that includes the specified date.static Period
createMaximumPeriod()
Creates a new Period instance that starts at the minimum value allowed by Date and ends at the maximum value allowed by Date.static Period
createMonthPeriod(long timestamp)
Creates a new Period instance that matches exactly the month that includes the specified time stamp.static Period
createMonthPeriod(String date)
Creates a new Period instance that matches exactly the month that includes the specified date.static Period
createPeriod(long start, long end)
static Period
createPeriod(String start, String end)
Creates a new custom period.static Period
createSinceDaysPeriod(int numberOfDays)
Creates a new Period instance that matches all the instants between N days before the instantiation and the instantiation.static Period
createSinceHoursPeriod(int numberOfHours)
Creates a new Period instance that matches all the instants between N hours before the instantiation and the instantiation.static Period
createSinceMonthsPeriod(int numberOfMonths)
Creates a new Period instance that matches all the instants between N months before the instantiation and the instantiation.static Period
createSinceWeeksPeriod(int numberOfWeeks)
Creates a new Period instance that matches all the instants between N weeks before the instantiation and the instantiation.static Period
createSinceYearsPeriod(int numberOfYears)
Creates a new Period instance that matches all the instants between N years before the instantiation and the instantiation.static Period
createWeekPeriod(long timestamp)
Creates a new Period instance that matches exactly the week that includes the specified time stamp.static Period
createWeekPeriod(String date)
Creates a new Period instance that matches exactly the week that includes the specified date.static Period
createYearPeriod(long timestamp)
Creates a new Period instance that matches exactly the year that includes the specified time stamp.static Period
createYearPeriod(String date)
Creates a new Period instance that matches exactly the year that includes the specified date.static Period
getALL_TIME()
Helper method for accessingALL_TIME
static field in velocitystatic Period
getCurrentDay()
static Period
getCurrentMonth()
static Period
getCurrentWeek()
static Period
getCurrentYear()
-
-
-
Field Detail
-
ALL_TIME
public static final Period ALL_TIME
-
-
Method Detail
-
createPeriod
public static Period createPeriod(long start, long end)
- See Also:
Period(long, long)
-
createPeriod
public static Period createPeriod(String start, String end)
Creates a new custom period. The start and end dates must have the following format: "yyyyMMdd" .- Parameters:
start
- The start dateend
- The end date- Returns:
- A new Period instance
- See Also:
SimpleDateFormat
-
createDayPeriod
public static Period createDayPeriod(long timestamp)
Creates a new Period instance that matches exactly the day that includes the specified time stamp.- Parameters:
timestamp
- The milliseconds from 1970-01-01T00:00:00Z- Returns:
- A new Period instance
-
createDayPeriod
public static Period createDayPeriod(String date)
Creates a new Period instance that matches exactly the day that includes the specified date.- Parameters:
date
- The string representation of a date uniquely identifying a day. Use the "yyyyMMdd" format.- Returns:
- The corresponding Period object
- See Also:
SimpleDateFormat
-
createHourPeriod
public static Period createHourPeriod(long timestamp)
Creates a new Period instance that matches exactly the hour that includes the specified time stamp.- Parameters:
timestamp
- The milliseconds from 1970-01-01T00:00:00Z- Returns:
- A new Period instance
-
createHourPeriod
public static Period createHourPeriod(String date)
Creates a new Period instance that matches exactly the hour that includes the specified date.- Parameters:
date
- The string representation of a date uniquely identifying a day. Use the "yyyyMMdd" format.- Returns:
- The corresponding Period object
- See Also:
SimpleDateFormat
-
createSinceHoursPeriod
public static Period createSinceHoursPeriod(int numberOfHours)
Creates a new Period instance that matches all the instants between N hours before the instantiation and the instantiation.- Parameters:
numberOfHours
- number of hours to substract from current date- Returns:
- The corresponding period object
-
createSinceDaysPeriod
public static Period createSinceDaysPeriod(int numberOfDays)
Creates a new Period instance that matches all the instants between N days before the instantiation and the instantiation.- Parameters:
numberOfDays
- number of days to substract from current date- Returns:
- The corresponding period object
-
createSinceWeeksPeriod
public static Period createSinceWeeksPeriod(int numberOfWeeks)
Creates a new Period instance that matches all the instants between N weeks before the instantiation and the instantiation.- Parameters:
numberOfWeeks
- number of weeks to substract from current date- Returns:
- The corresponding period object
-
createSinceMonthsPeriod
public static Period createSinceMonthsPeriod(int numberOfMonths)
Creates a new Period instance that matches all the instants between N months before the instantiation and the instantiation.- Parameters:
numberOfMonths
- number of months to substract from current date- Returns:
- The corresponding period object
-
createSinceYearsPeriod
public static Period createSinceYearsPeriod(int numberOfYears)
Creates a new Period instance that matches all the instants between N years before the instantiation and the instantiation.- Parameters:
numberOfYears
- number of years to substract from current date- Returns:
- The corresponding period object
-
getCurrentDay
public static Period getCurrentDay()
- Returns:
- The period of time matching the current day
-
createWeekPeriod
public static Period createWeekPeriod(long timestamp)
Creates a new Period instance that matches exactly the week that includes the specified time stamp.- Parameters:
timestamp
- The milliseconds from 1970-01-01T00:00:00Z- Returns:
- A new Period instance
-
createWeekPeriod
public static Period createWeekPeriod(String date)
Creates a new Period instance that matches exactly the week that includes the specified date.- Parameters:
date
- The string representation of a date uniquely identifying a week. Use the "yyyyMMdd" format.- Returns:
- The corresponding Period object
- See Also:
SimpleDateFormat
-
getCurrentWeek
public static Period getCurrentWeek()
- Returns:
- The period of time matching the current week
-
createMonthPeriod
public static Period createMonthPeriod(long timestamp)
Creates a new Period instance that matches exactly the month that includes the specified time stamp.- Parameters:
timestamp
- The milliseconds from 1970-01-01T00:00:00Z- Returns:
- A new Period instance
-
createMonthPeriod
public static Period createMonthPeriod(String date)
Creates a new Period instance that matches exactly the month that includes the specified date.- Parameters:
date
- The string representation of a date uniquely identifying a month. Use the "yyyyMMdd" format.- Returns:
- The corresponding Period object
- See Also:
SimpleDateFormat
-
getCurrentMonth
public static Period getCurrentMonth()
- Returns:
- The period of time matching the current month
-
createYearPeriod
public static Period createYearPeriod(long timestamp)
Creates a new Period instance that matches exactly the year that includes the specified time stamp.- Parameters:
timestamp
- The milliseconds from 1970-01-01T00:00:00Z- Returns:
- A new Period instance
-
createYearPeriod
public static Period createYearPeriod(String date)
Creates a new Period instance that matches exactly the year that includes the specified date.- Parameters:
date
- The string representation of a date uniquely identifying a year. Use the "yyyyMMdd" format.- Returns:
- The corresponding Period object
- See Also:
SimpleDateFormat
-
createMaximumPeriod
public static Period createMaximumPeriod()
Creates a new Period instance that starts at the minimum value allowed by Date and ends at the maximum value allowed by Date.- Returns:
- The corresponding Period object
-
getCurrentYear
public static Period getCurrentYear()
- Returns:
- The period of time matching the current year
-
-