public final class TimePeriod extends Object implements Serializable
Constructor and Description |
---|
TimePeriod(Date startTime,
Date endTime)
Constructs a new time period.
|
Modifier and Type | Method and Description |
---|---|
List<TimePeriod> |
breakDownDaily(TimeZone timeZone)
Breaks the time period down to days.
|
List<TimePeriod> |
breakDownHourly(TimeZone timeZone)
Breaks the time period down to days.
|
List<TimePeriod> |
breakDownMonthly(TimeZone timeZone)
Breaks the time period down to months.
|
List<TimePeriod> |
breakDownWeekly(TimeZone timeZone)
Breaks the time period down to weeks.
|
List<TimePeriod> |
breakDownYearly(TimeZone timeZone)
Breaks the time period down to years.
|
boolean |
equals(Object obj) |
static TimePeriod |
getDayPeriod(Date time,
TimeZone timeZone)
Gets the one-day period the given point in time belongs to.
|
Date |
getEndTime()
Gets the end time.
|
static TimePeriod |
getHourPeriod(Date time,
TimeZone timeZone)
Gets the one-hour period the given point in time belongs to.
|
static TimePeriod |
getMonthPeriod(Date time,
TimeZone timeZone)
Gets the one-month period the given point in time belongs to.
|
Date |
getStartTime()
Gets the start time.
|
static Date[] |
getWeekDays(Date time,
TimeZone timeZone)
Gets the week the given point in time belongs to.
|
static TimePeriod |
getWeekPeriod(Date time,
TimeZone timeZone)
Gets the one-week period the given point in time belongs to.
|
static TimePeriod |
getYearPeriod(Date time,
TimeZone timeZone)
Gets the one-year period the given point in time belongs to.
|
int |
hashCode() |
static boolean |
isValidPeriod(Date startTime,
Date endTime)
Verifies whether the given dates conform a valid time period.
|
String |
toString() |
public TimePeriod(Date startTime, Date endTime) throws NullPointerException, IllegalArgumentException
startTime
- start timeendTime
- end timeNullPointerException
- if either startTime
or endTime
is null
IllegalArgumentException
- if startTime
does not happen before endTime
public Date getStartTime()
public Date getEndTime()
public static boolean isValidPeriod(Date startTime, Date endTime)
startTime
- start timeendTime
- end timetrue
if startTime
and endTime
conform a valid time period,
false
otherwisepublic static TimePeriod getHourPeriod(Date time, TimeZone timeZone)
time
- reference point in timetimeZone
- time zone. See TimeZone.getDefault()
time
belongs
to and the end time is the end of the daypublic static TimePeriod getDayPeriod(Date time, TimeZone timeZone)
time
- reference point in timetimeZone
- time zone; see TimeZone.getDefault()
time
belongs
to and the end time is the end of the daypublic static TimePeriod getWeekPeriod(Date time, TimeZone timeZone)
time
- reference point in timetimeZone
- time zone; see TimeZone.getDefault()
time
belongs
to and the end time is the end of the weekpublic static Date[] getWeekDays(Date time, TimeZone timeZone)
time
- reference point in timetimeZone
- time zone; see TimeZone.getDefault()
public static TimePeriod getMonthPeriod(Date time, TimeZone timeZone)
time
- reference point in timetimeZone
- time zone; see TimeZone.getDefault()
time
belongs
to and the end time is the end of the monthpublic static TimePeriod getYearPeriod(Date time, TimeZone timeZone)
time
- reference point in timetimeZone
- time zone; see TimeZone.getDefault()
time
belongs
to and the end time is the end of the yearpublic List<TimePeriod> breakDownHourly(TimeZone timeZone)
timeZone
- time zone; see TimeZone.getDefault()
public List<TimePeriod> breakDownDaily(TimeZone timeZone)
timeZone
- time zone; see TimeZone.getDefault()
public List<TimePeriod> breakDownWeekly(TimeZone timeZone)
timeZone
- time zone; see TimeZone.getDefault()
public List<TimePeriod> breakDownMonthly(TimeZone timeZone)
timeZone
- time zone; see TimeZone.getDefault()
public List<TimePeriod> breakDownYearly(TimeZone timeZone)
timeZone
- time zone; see TimeZone.getDefault()
Copyright © 2015. All Rights Reserved.