public class

DateTimeRange

extends Object
java.lang.Object
   ↳ com.google.api.gbase.client.DateTimeRange

Class Overview

A date or date/time range, with a start and end DateTime. Since dateTimeRange is a superclass of date and dateTime, a DateTimeRange object can sometimes be used to represent a single date or dateTime. When this is the case, the start and end value will be identical and isDateTimeOnly() will return true. You can then get the DateTime the 'range' corresponds to using toDateTime().

Summary

Fields
private final DateTime end The end date/time of this range.
private final DateTime start The start date/time of this range.
Public Constructors
DateTimeRange(DateTime start, DateTime end)
Creates a new range.
DateTimeRange(DateTime dateTime)
Creates a new range that is actually a date or a dateTime.
Public Methods
boolean equals(Object o)
DateTime getEnd()
Gets the end date or date/time.
DateTime getStart()
Gets the start date or date+time.
int hashCode()
boolean isDateTimeOnly()
Checks whether this is a real range, with a start and an end date, or a date/dateTime posing as a range.
DateTime toDateTime()
Converts empty ranges into DateTime.
String toString()
Returns the canonical string representation for a range, as used in the XML (start " " end).
[Expand]
Inherited Methods
From class java.lang.Object

Fields

private final DateTime end

The end date/time of this range.

private final DateTime start

The start date/time of this range.

Public Constructors

public DateTimeRange (DateTime start, DateTime end)

Creates a new range.

Parameters
start
end
Throws
IllegalArgumentException if either start or end is null

public DateTimeRange (DateTime dateTime)

Creates a new range that is actually a date or a dateTime. Empty ranges (with start date the same as the end dates) can be detected using isDateTimeOnly() and then converted using toDateTime().

Parameters
dateTime

Public Methods

public boolean equals (Object o)

Parameters
o

public DateTime getEnd ()

Gets the end date or date/time.

public DateTime getStart ()

Gets the start date or date+time.

public int hashCode ()

public boolean isDateTimeOnly ()

Checks whether this is a real range, with a start and an end date, or a date/dateTime posing as a range. This hack is necessary to handle treating DateTime as a DateTimeRange, because dateTimeRange is a supertype of date and dateTime. If this method returns true, you can get the DateTime object this object corresponds to using toDateTime()

Returns
  • true if start is the same as end

public DateTime toDateTime ()

Converts empty ranges into DateTime.

Returns
  • a DateTime object
Throws
IllegalStateException if the start and end date are distinct, which means the dateTimeRange is neither a date nor a dateTime (see isDateTimeOnly())

public String toString ()

Returns the canonical string representation for a range, as used in the XML (start " " end).