com.silverpeas.calendar
Interface Datable<T extends Datable<? super T>>

Type Parameters:
T - A datable type this class should generate.
All Superinterfaces:
Cloneable
All Known Implementing Classes:
AbstractDateDatable, Date, DateTime

public interface Datable<T extends Datable<? super T>>
extends Cloneable

A datable object is an object that represents a date in Silverpeas, whatever it is. It can be a simple date (day in month in year) or a more complete one like a date time. Dates and datetimes are differents types as they don't have any instances in common, but they are part of the same types class. As Java doesn't support the trait concept from which a polymorphic familly of types can be modeled, the datable class is here introduced by a Java interface with a generic type. Datable can be then considered as a type generator that satisfy a bound constraint (a fix point).


Field Summary
static String ICAL_PATTERN
          The pattern for the iCal date representation in the current time zone of the datable.
static String ICAL_UTC_PATTERN
          The pattern for the iCal date representation in UTC.
static String ISO_8601_PATTERN
          The pattern for the ISO 8601 date representation.
static String SHORT_ISO_8601_PATTERN
          The pattern for the short ISO 8601 date representation.
 
Method Summary
 T addDays(int amount)
          Adds a number of days to the datable instance returning a new one.
 T addHours(int amount)
          Adds a number of hours to the datable instance returning a new one.
 T addMilliseconds(int amount)
          Adds a number of milliseconds to the datable instance returning a new one.
 T addMinutes(int amount)
          Adds a number of minutes to the datable instance returning a new one.
 T addMonths(int amount)
          Adds a number of months to the datable instance returning a new one.
 T addSeconds(int amount)
          Adds a number of seconds to the datable instance returning a new one.
 T addWeeks(int amount)
          Adds a number of weeks to the datable instance returning a new one.
 T addYears(int amount)
          Adds a number of years to the datable instance returning a new one.
 Date asDate()
          Gets the java Date representation of this datable.
 T clone()
          Clones itself.
 T getBeginOfDay()
          Computes first hour, minute, second, millisecond from the datable instance.
 T getBeginOfMonth()
          Compute the first hour, minute, second, millisecond from the datable instance.
 T getBeginOfWeek()
          Compute the first hour, minute, second, millisecond from the datable instance.
 T getBeginOfWeek(String locale)
          Compute the first hour, minute, second, millisecond from the datable instance and a given locale.
 T getBeginOfYear()
          Compute the first hour, minute, second, millisecond from the datable instance.
 T getEndOfDay()
          Computes first hour, minute, second, millisecond from the datable instance.
 T getEndOfMonth()
          Compute the date of the first day in the month from the datable instance.
 T getEndOfWeek()
          Compute the date of the first day in the week from the datable instance.
 T getEndOfWeek(String locale)
          Compute the date of the first day in the week from the datable instance and a given locale.
 T getEndOfYear()
          Compute the date of the first day in the year from the datable instance.
 TimeData getTimeDataTo(T anotherDatable)
          Compute the time between the datable instance and another one.
 TimeZone getTimeZone()
          Gets the time zone for which this datable is defined.
 T inTimeZone(TimeZone timeZone)
          Sets the time zone this datable is defined for.
 boolean isAfter(T anotherDatable)
          Is this datable strictly after in time the specified another one?
 boolean isBefore(T anotherDatable)
          Is this datable strictly before in time the specified another one?
 boolean isDefined()
          Indicates is the date is different from DateUtil.MINIMUM_DATE or DateUtil.MAXIMUM_DATE.
 boolean isEqualTo(T anotherDatable)
          Is this datable equal in time to the specified another one?
 boolean isNotDefined()
          Indicates the opposite of isDefined()
 String toICal()
          Gets the ISO 8601 textual representation of this date as it is in the iCal specification.
 String toICalInUTC()
          Gets the ISO 8601 textual representation of this date as it is in the iCal specification.
 String toISO8601()
          Gets an ISO 8601 textual representation of this datable by taking into account of its underlying timezone.
 String toShortISO8601()
          Gets an ISO 8601 textual representation of this datable by taking into account of its underlying timezone.
 

Field Detail

SHORT_ISO_8601_PATTERN

static final String SHORT_ISO_8601_PATTERN
The pattern for the short ISO 8601 date representation. The date is at the accuracy to the minute and the time zone is specified as defined in the RFC 822 (indicated by the Z symbol).

See Also:
Constant Field Values

ISO_8601_PATTERN

static final String ISO_8601_PATTERN
The pattern for the ISO 8601 date representation. The date is at the accuracy to the second and the time zone is specified as defined in the RFC 822 (indicated by the Z symbol).

See Also:
Constant Field Values

ICAL_PATTERN

static final String ICAL_PATTERN
The pattern for the iCal date representation in the current time zone of the datable.

See Also:
Constant Field Values

ICAL_UTC_PATTERN

static final String ICAL_UTC_PATTERN
The pattern for the iCal date representation in UTC. The UTC set of the date is indicated here by the Z character.

See Also:
Constant Field Values
Method Detail

clone

T clone()
Clones itself.

Returns:
a clone to this datable.

asDate

Date asDate()
Gets the java Date representation of this datable.

Returns:
a Date representation of this datable.

isBefore

boolean isBefore(T anotherDatable)
Is this datable strictly before in time the specified another one?

Parameters:
anotherDatable - the another datable to which this is compared.
Returns:
true if this datable is strictly before the another one.

isAfter

boolean isAfter(T anotherDatable)
Is this datable strictly after in time the specified another one?

Parameters:
anotherDatable - the another datable to which this is compared.
Returns:
true if this datable is strictly after the another one.

isEqualTo

boolean isEqualTo(T anotherDatable)
Is this datable equal in time to the specified another one?

Parameters:
anotherDatable - the another datable to which this is compared.
Returns:
true if this datable is equal with the another one.

inTimeZone

T inTimeZone(TimeZone timeZone)
Sets the time zone this datable is defined for. If no time zone is set, then the default one is considered (the timezone of the host). The time zone can have no meaning with some datable types like for example simple date (day, month, and year).

Parameters:
timeZone - the time zone of this datable.
Returns:
itself.

getTimeZone

TimeZone getTimeZone()
Gets the time zone for which this datable is defined.

Returns:
the time zone of this datable.

toISO8601

String toISO8601()
Gets an ISO 8601 textual representation of this datable by taking into account of its underlying timezone. For date and time, the representation is at the accuracy to the second. The ISO 8601 format in which the date is returned is one of the more common in the Web, that is with the date and time separators (the hyphen for dates and the double-points for times): yyyy-MM-dd'T'HH:mm:ss where yyyy means the year in 4 digits, MM means the month in year in two digits, dd means the day in month in two digits, HH means the hour (24-o'clock) in two digits, mm means the minute in two digits, and ss the second in two digits.

Returns:
the ISO 8601 textual representation of this datable.

toShortISO8601

String toShortISO8601()
Gets an ISO 8601 textual representation of this datable by taking into account of its underlying timezone. For date and time, the representation is at the accuracy to the minute. The ISO 8601 format in which the date is returned is one of the more common in the Web, that is with the date and time separators (the hyphen for dates and the double-points for times): yyyy-MM-dd'T'HH:mm:ss where yyyy means the year in 4 digits, MM means the month in year in two digits, dd means the day in month in two digits, HH means the hour (24-o'clock) in two digits, and mm means the minute in two digits.

Returns:
a short ISO 8601 textual representation of this datable.

toICal

String toICal()
Gets the ISO 8601 textual representation of this date as it is in the iCal specification. The returned iCal date representation is in this datable's time zone. In the iCal specification, dates are represented in one of the ISO 8601 format, that is the complete format without any date and time separators (the hyphen character for dates and the double-points for times). In the iCal specification, no time zone information is added to the ISO 8601 representation of the date, nevertheless when the date is indicated in UTC, the 'Z' marker must be set in the date as required by the ISO 8601 standard.

Returns:
the iCal textual representation of this datable and in the timezone of this datable.

toICalInUTC

String toICalInUTC()
Gets the ISO 8601 textual representation of this date as it is in the iCal specification. The returned iCal date representation is in explicitly set in UTC. In the iCal specification, dates are represented in one of the ISO 8601 format, that is the complete format without any date and time separators (the hyphen character for dates and the double-points for times). In the iCal specification, no time zone information is added to the ISO 8601 representation of the date, nevertheless when the date is indicated in UTC, the 'Z' marker must be set in the date as required by the ISO 8601 standard.

Returns:
the iCal textual representation of this datable and in UTC.

getBeginOfDay

T getBeginOfDay()
Computes first hour, minute, second, millisecond from the datable instance.

Returns:
a date at last hour, minute, second and millisecond of the datable instance.

getEndOfDay

T getEndOfDay()
Computes first hour, minute, second, millisecond from the datable instance.

Returns:
a date at last hour, minute, second and millisecond of the datable instance.

getBeginOfWeek

T getBeginOfWeek()
Compute the first hour, minute, second, millisecond from the datable instance.

Returns:
a date at last hour, minute, second and millisecond of the datable instance.

getEndOfWeek

T getEndOfWeek()
Compute the date of the first day in the week from the datable instance.

Returns:
a date for the first day of the week of the datable instance.

getBeginOfWeek

T getBeginOfWeek(String locale)
Compute the first hour, minute, second, millisecond from the datable instance and a given locale.

Returns:
a date at last hour, minute, second and millisecond of the datable instance.

getEndOfWeek

T getEndOfWeek(String locale)
Compute the date of the first day in the week from the datable instance and a given locale.

Returns:
a date for the first day of the week of the datable instance.

getBeginOfMonth

T getBeginOfMonth()
Compute the first hour, minute, second, millisecond from the datable instance.

Returns:
a date at last hour, minute, second and millisecond of the datable instance.

getEndOfMonth

T getEndOfMonth()
Compute the date of the first day in the month from the datable instance.

Returns:
a date for the first day of the month of the datable instance.

getBeginOfYear

T getBeginOfYear()
Compute the first hour, minute, second, millisecond from the datable instance.

Returns:
a date at last hour, minute, second and millisecond of the datable instance.

getEndOfYear

T getEndOfYear()
Compute the date of the first day in the year from the datable instance.

Returns:
a date for the first day of the year of the datable instance.

getTimeDataTo

TimeData getTimeDataTo(T anotherDatable)
Compute the time between the datable instance and another one.

Returns:
the time between the datable instance and another one represented by TimeData.

addYears

T addYears(int amount)
Adds a number of years to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

addMonths

T addMonths(int amount)
Adds a number of months to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

addWeeks

T addWeeks(int amount)
Adds a number of weeks to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

addDays

T addDays(int amount)
Adds a number of days to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

addHours

T addHours(int amount)
Adds a number of hours to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

addMinutes

T addMinutes(int amount)
Adds a number of minutes to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

addSeconds

T addSeconds(int amount)
Adds a number of seconds to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

addMilliseconds

T addMilliseconds(int amount)
Adds a number of milliseconds to the datable instance returning a new one. The original Datable is unchanged.

Parameters:
amount - the amount to add, may be negative
Returns:
the new Datable with the amount added

isDefined

boolean isDefined()
Indicates is the date is different from DateUtil.MINIMUM_DATE or DateUtil.MAXIMUM_DATE.

Returns:
true if the date is not equal to undifined one, false otherwise.

isNotDefined

boolean isNotDefined()
Indicates the opposite of isDefined()

Returns:


Copyright © 2016 Silverpeas. All Rights Reserved.