|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.silverpeas.date.Period
public class Period
Class representing a period between two dates and offering tools around it.
User: Yohann Chastagnier Date: 19/04/13
Field Summary | |
---|---|
static Period |
UNDEFINED
|
Constructor Summary | |
---|---|
protected |
Period(DateTime beginDatable,
DateTime endDatable)
Constructor : Constructs a newly allocated period . |
protected |
Period(DateTime beginDatable,
DateTime endDatable,
TimeZone timeZone)
Constructor : Constructs a newly allocated period . |
Method Summary | |
---|---|
static Period |
check(Period period)
Checks if the specified period and returns the specified one if defined, or the common UNDEFINED otherwise. |
Period |
clone()
|
int |
compareTo(Object o)
|
int |
compareTo(Period period)
The comparison is at first time executed on the begin dates. |
boolean |
contains(Date date)
Checks if the given date is included in the period. |
boolean |
contains(Period period)
Checks if the given period is included in the period. |
boolean |
containsPartOf(Period period)
Checks if the given period is partially included in the period. |
boolean |
equals(Object o)
|
protected String |
formatPeriodForTests()
|
static Period |
from(Date beginDate,
Date endDate)
Initialize a period from given dates. |
static Period |
from(Date beginDate,
Date endDate,
TimeZone timeZone)
Initialize a period from given dates. |
static Period |
from(Date referenceDate,
PeriodType periodType)
Initialize a period from a date and a type of period. |
static Period |
from(Date referenceDate,
PeriodType periodType,
String locale)
Initialize a period from a date and a type of period. |
static Period |
from(DateTime beginDatable,
DateTime endDatable)
Initialize a period from given dates. |
static Period |
from(DateTime referenceDatable,
PeriodType periodType)
Initialize a period from a date and a type of period. |
static Period |
from(DateTime referenceDatable,
PeriodType periodType,
String locale)
Initialize a period from a date and a type of period. |
static Period |
from(Date referenceDate,
TimeZone timeZone,
PeriodType periodType)
Initialize a period from a date and a type of period. |
static Period |
from(Date referenceDate,
TimeZone timeZone,
PeriodType periodType,
String locale)
Initialize a period from a date and a type of period. |
DateTime |
getBeginDatable()
Gets the begin date of the period represented as a Datable . |
Date |
getBeginDate()
Gets the begin date of the period. |
TimeData |
getCoveredDaysTimeData()
Computes the number of whole or partial days covered by the period. |
TimeData |
getElapsedTimeData()
Computes the elapsed time between the begin and the end dates. |
DateTime |
getEndDatable()
Gets the end date of the period represented as a Datable . |
Date |
getEndDate()
Gets the end date of the period. |
PeriodType |
getPeriodType()
Gets the type of the period. |
static Period |
getPeriodWithUndefinedIfNull(Date beginDate,
Date endDate)
Initialize a period from given dates (undefined dates are taken into account for null ones). |
TimeZone |
getTimeZone()
The time zone has no meaning for a date. |
int |
hashCode()
|
Period |
inTimeZone(TimeZone timeZone)
The time zone for a period has no meaning. |
boolean |
isBeginDefined()
This method is a shortcut of isDefined() call on getBeginDatable() . |
boolean |
isBeginNotDefined()
This method is a shortcut of isNotDefined() call on getBeginDatable() . |
boolean |
isDefined()
Indicates if one of begin date or end date is defined. |
boolean |
isEndDefined()
This method is a shortcut of isDefined() call on getEndDatable() . |
boolean |
isEndNotDefined()
This method is a shortcut of isNotDefined() call on getEndDatable() . |
boolean |
isLongerThan(Period period)
Indicates if the period is longer than th given one. |
boolean |
isNotDefined()
Indicates the opssite of isDefined() . |
boolean |
isValid()
Indicates if the period is valid. |
void |
setDate(Date dateReference,
PeriodType periodType)
Sets the begin and the end dates of the period. |
void |
setDate(DateTime referenceDatable,
PeriodType periodType)
Sets the begin and the end dates of the period. |
void |
setDate(Date dateReference,
TimeZone timeZone,
PeriodType periodType)
Sets the begin and the end dates of the period. |
void |
setDates(Date beginDate,
Date endDate)
Sets the begin and the end dates of the period. |
void |
setDates(Date beginDate,
Date endDate,
TimeZone timeZone)
Sets the begin and the end dates of the period. |
void |
setDates(DateTime beginDatable,
DateTime endDatable)
Sets the begin and the end dates of the period. |
protected void |
setPeriodType(PeriodType periodType)
Sets the type of the period. |
String |
toString()
For debugging. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Period UNDEFINED
Constructor Detail |
---|
protected Period(DateTime beginDatable, DateTime endDatable)
period
.
TimeZone is set from the begin date of the period.
beginDatable
- the date of the beginning of the period.endDatable
- the date of the ending of the period.protected Period(DateTime beginDatable, DateTime endDatable, TimeZone timeZone)
period
.
beginDatable
- the date of the beginning of the period.endDatable
- the date of the ending of the period.timeZone
- the time zone to set to this period.Method Detail |
---|
public static Period check(Period period)
UNDEFINED
otherwise.
period
-
UNDEFINED
otherwise.public static Period getPeriodWithUndefinedIfNull(Date beginDate, Date endDate)
PeriodType
).
beginDate
- the date of the beginning of the period.endDate
- the date of the ending of the period.
public static Period from(Date beginDate, Date endDate)
PeriodType
).
beginDate
- the date of the beginning of the period.endDate
- the date of the ending of the period.
public static Period from(Date beginDate, Date endDate, TimeZone timeZone)
PeriodType
).
beginDate
- the date of the beginning of the period.endDate
- the date of the ending of the period.timeZone
- the time zone to set to this period.
public static Period from(DateTime beginDatable, DateTime endDatable)
PeriodType
).
beginDatable
- the date of the beginning of the period.endDatable
- the date of the ending of the period.
public static Period from(Date referenceDate, PeriodType periodType)
referenceDate
- periodType
-
public static Period from(Date referenceDate, TimeZone timeZone, PeriodType periodType)
referenceDate
- timeZone
- periodType
-
public static Period from(DateTime referenceDatable, PeriodType periodType)
referenceDatable
- periodType
-
public static Period from(Date referenceDate, PeriodType periodType, String locale)
referenceDate
- periodType
- locale
-
public static Period from(Date referenceDate, TimeZone timeZone, PeriodType periodType, String locale)
referenceDate
- timeZone
- periodType
- locale
-
public static Period from(DateTime referenceDatable, PeriodType periodType, String locale)
referenceDatable
- periodType
- locale
-
public boolean isDefined()
public boolean isNotDefined()
isDefined()
.
public Period inTimeZone(TimeZone timeZone)
timeZone
- the time zone to set to this period.public TimeZone getTimeZone()
public PeriodType getPeriodType()
protected void setPeriodType(PeriodType periodType)
periodType
- public Date getBeginDate()
public Date getEndDate()
public DateTime getBeginDatable()
Datable
.
(see getBeginDate()
for more details).
public boolean isBeginDefined()
isDefined()
call on getBeginDatable()
.
getBeginDatable()
returns defined date, false otherwise.public boolean isBeginNotDefined()
isNotDefined()
call on getBeginDatable()
.
getBeginDatable()
returns a not defined date, false otherwise.public DateTime getEndDatable()
Datable
.
(see getEndDate()
for more details).
public boolean isEndDefined()
isDefined()
call on getEndDatable()
.
getEndDatable()
returns defined date, false otherwise.public boolean isEndNotDefined()
isNotDefined()
call on getEndDatable()
.
getEndDatable()
returns a not defined date, false otherwise.public void setDate(Date dateReference, PeriodType periodType)
dateReference
- public void setDate(Date dateReference, TimeZone timeZone, PeriodType periodType)
dateReference
- timeZone
- public void setDate(DateTime referenceDatable, PeriodType periodType)
referenceDatable
- public void setDates(Date beginDate, Date endDate)
beginDate
- public void setDates(Date beginDate, Date endDate, TimeZone timeZone)
beginDate
- timeZone
- public void setDates(DateTime beginDatable, DateTime endDatable)
beginDatable
- public TimeData getElapsedTimeData()
TimeData
.
To retrieve informations from this returned object :
// Gets the elpased time in milliseconds
period.getElapsedTimeData().getTime();
// Gets the elpased time in seconds
period.getElapsedTimeData().getTimeConverted(TimeUnit.SEC);
// Gets the elpased time in years
period.getElapsedTimeData().getTimeConverted(TimeUnit.YEAR);
...
// Gets the elpased time in the best unit value
period.getElapsedTimeData().getBestValue();
public TimeData getCoveredDaysTimeData()
TimeData
.
To retrieve informations from this returned object :
// Gets the number of days (in milliseconds)
period.getCoveredDaysTimeData().getTime();
// Gets the number of days (in days)
period.getCoveredDaysTimeData().getTimeConverted(TimeUnit.DAY);
...
// Gets the number of days (in best unit value)
period.getCoveredDaysTimeData().getBestValue();
public int compareTo(Object o)
compareTo
in interface Comparable
public int compareTo(Period period)
period
-
public boolean isLongerThan(Period period)
period
-
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public boolean isValid()
public String toString()
toString
in class Object
protected String formatPeriodForTests()
public boolean contains(Date date)
date
- a date
true
if the given date is included in the period.public boolean contains(Period period)
period
- a period
true
if the given period is included in the period.public boolean containsPartOf(Period period)
period
- Une date
true
if the given period is partially included in the period.public Period clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |