# Google Data APIs Client Library (1.43.0)

## com.google.api.gbase.client
Class DateTimeRange

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

    public class DateTimeRange

extends java.lang.Object

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()`.

Constructor Summary
`DateTimeRange(DateTime dateTime)` Creates a new range that is actually a date or a dateTime.
`DateTimeRange(DateTime start, DateTime end)` Creates a new range.

Method Summary
`boolean` `equals(java.lang.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`.
`java.lang.String` `toString()` Returns the canonical string representation for a range, as used in the XML (start " " end).

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DateTimeRange

    public DateTimeRange(DateTime start,
                         DateTime end)

  Creates a new range.

  Parameters:
    `start` -
    `end` -
  Throws:
    `java.lang.IllegalArgumentException` - if either start or end is null

### DateTimeRange

    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` -

Method Detail

### isDateTimeOnly

    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

### toDateTime

    public DateTime toDateTime()

  Converts empty ranges into `DateTime`.

  Returns:
    a DateTime object
  Throws:
    `java.lang.IllegalStateException` - if the start and end date are distinct, which means the dateTimeRange is neither a date nor a dateTime (see `isDateTimeOnly()`)

### getStart

    public DateTime getStart()

  Gets the start date or date+time.

### getEnd

    public DateTime getEnd()

  Gets the end date or date/time.

### toString

    public java.lang.String toString()

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

  Overrides:
    `toString` in class `java.lang.Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### equals

    public boolean equals(java.lang.Object o)

  Overrides:
    `equals` in class `java.lang.Object`