|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcoderz.commons.types.Period
public final class Period
A Period data type represents a period in time.
There are two types of periods. One that is day bound and the other one is milli-second bound. The day bound period has just set the hours, minutes, seconds, and milli-seconds set to zero. In other words, the first one is in day resolution whereas the second one is in milli-second resolution.
TODO: Refine
| Field Summary | |
|---|---|
static String |
TYPE_NAME
The name of this type. |
| Method Summary | |
|---|---|
boolean |
after(Period other)
Checks if this period is after the given period. |
boolean |
before(Period other)
Checks if this period is before the given period. |
static Period |
createDayPeriod(Date date)
A factory method to create a day period. |
static Period |
createDayPeriod(Date start,
Date end)
A factory method to create a period from two timestamps where the hours, minutes, seconds, and milli-seconds are stripped off. |
static Period |
createMonthPeriod(Date date)
A factory method to create a month period. |
static Period |
createPeriod(Date start,
Date end)
A factory method to create a period from two timestamps of the type Date. |
long |
duration()
Returns the duration of this Period in milliseconds. |
boolean |
equals(Object o)
|
Date |
getEndTime()
Returns the end date of the period. |
Date |
getNextPeriodStartTime()
Returns the start time for the next period. |
Date |
getPrevPeriodEndTime()
Returns the end time of the previous period. |
Date |
getStartTime()
Returns the start date of the period. |
int |
hashCode()
|
Period |
intersection(Period other)
Returns the intersection of two periods. |
boolean |
isIncluded(Date date)
Checks whether a specified date falls into the period defined by the instance. |
boolean |
isIncluded(Period other)
Checks whether a specified period falls into the period defined by the instance. |
Period |
minus(long offset)
Returns a Period object whose start/end time lies exactly offset milliseconds before the start/end time of this period. |
Period |
next()
Returns the next Period. |
Period |
nextDay()
Returns the day period, that lies after this period. |
static Period |
nextDay(Date date)
Returns the day period, that lies after the given date. |
Period |
nextHour()
Returns the next clock hour period, that lies after this period. |
static Period |
nextHour(Date date)
Returns the next clock hour period, that lies after the given date. |
Period |
nextMonth()
Returns the month period, that lies after this period. |
static Period |
nextMonth(Date date)
Returns the month period, that lies after the given date. |
boolean |
overlap(Period period)
Checks whether a specified period overlaps with this period. |
Period |
plus(long offset)
Returns a Period object whose start/end time lies exactly offset milliseconds after the start/end time of this period. |
Period |
previous()
Returns the previous Period. |
Period |
previousDay()
Returns the day period, that lies before this period. |
static Period |
previousDay(Date date)
Returns the day period, that lies before the given date. |
Period |
previousHour()
Returns the next clock hour period, that lies this this period. |
static Period |
previousHour(Date date)
Returns the previous clock hour period, that lies befor the given date. |
Period |
previousMonth()
Returns the month period, that lies before this period. |
static Period |
previousMonth(Date date)
Returns the month period, that lies before the given date. |
String |
toString()
|
Period |
union(Period other)
Returns the union of two periods. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String TYPE_NAME
| Method Detail |
|---|
public static Period createPeriod(Date start,
Date end)
throws ArgumentMalformedException
Date.
start - The start time to create the period from.end - The end time to create the period from.
ArgumentMalformedException - when the end date is before the start
date.
public static Period createDayPeriod(Date start,
Date end)
throws ArgumentMalformedException
start - The start time to create the period from.end - The end time to create the period from.
ArgumentMalformedException - when the end date is before the start
date.
public static Period createDayPeriod(Date date)
throws ArgumentMalformedException
date. The duration of this period
is exactly Date.MILLIS_PER_DAY milliseconds.
Example: for the date 2004-09-03T11:52:03.437Z this method will return the
period 2004-09-03T00:00:00.000Z-2004-09-03T23:59:59.999Z.
date - The date that falls within the returned period.
ArgumentMalformedException - when the parameter date is
null.
public static Period createMonthPeriod(Date date)
throws ArgumentMalformedException
date. The duration of this period
is exactly the duration of the month of the date.
Example: for the date 2004-09-03T11:52:03.437Z this method will return a
period 2004-09-01T00:00:00.000Z-2004-09-30T23:59:59.999Z.
date - The date that falls within the returned period.
ArgumentMalformedException - when the parameter date is
null.public Date getStartTime()
public Date getEndTime()
public Period intersection(Period other)
other - The period that will be intersected with this instance.
public Period union(Period other)
other - The period to create a union period with this instance.
public boolean isIncluded(Date date)
date - The date that is checked whether it lies in the period.
public boolean isIncluded(Period other)
other - The period that is checked whether it lies in this period.
public boolean overlap(Period period)
period - The period to check for overlap with this period.
public Date getNextPeriodStartTime()
public Date getPrevPeriodEndTime()
public long duration()
public Period next()
public Period previous()
public Period plus(long offset)
offset milliseconds after the start/end time of this period.
offset - The offset in milliseconds.
offset milliseconds after the start/end time of this period.public static Period nextHour(Date date)
date.
Example: for the date 2004-09-03T11:52:03 this method will return the
period 2004-09-03T12:00:00.000Z-2004-09-03T12:59:59.999Z.
date - The date to get the next clock hour period.
date.public Period nextHour()
public static Period previousHour(Date date)
date.
Example: for the date 2004-09-03T11:52:03 this method will return the
period 2004-09-03T10:00:00.000Z-2004-09-03T10:59:59.999Z.
date - The date to get the previous clock hour period.
date.public Period previousHour()
public static Period nextDay(Date date)
date.
Example: for the date 2004-09-03T11:52:03 this method will return the
period 2004-09-04T00:00:00.000Z-2004-09-04T23:59:59.999Z.
date - The date to get the next day period.
date.public Period nextDay()
date.nextDay(Date)public static Period previousDay(Date date)
date.
Example: for the date 2004-09-03T11:52:03 this method will return the
period 2004-09-02T00:00:00.000Z-2004-09-02T23:59:59.999Z.
date - The date to get the previous day period.
date.public Period previousDay()
previousDay(Date)public static Period nextMonth(Date date)
date.
Example: for the date 2004-09-03T11:52:03 this method will return the
period 2004-10-01T00:00:00.000Z-2004-10-31T23:59:59.999Z.
date - The date to get the next month period.
date.public Period nextMonth()
nextMonth(Date)public static Period previousMonth(Date date)
date.
Example: for the date 2004-09-03T11:52:03 this method will return the
period 2004-08-01T00:00:00.000Z-2004-08-31T23:59:59.999Z.
date - The date to get the previous month period.
date.public Period previousMonth()
previousMonth(Date)public Period minus(long offset)
offset milliseconds before the start/end time of this period.
offset - The offset in milliseconds.
offset milliseconds before the start/end time of this period.public boolean before(Period other)
other - the period to compare with.
public boolean after(Period other)
other - the period to compare with.
public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||