com.google.api.adwords.lib
Class ReportDate

java.lang.Object
  extended by com.google.api.adwords.lib.ReportDate
All Implemented Interfaces:
java.lang.Comparable

public final class ReportDate
extends java.lang.Object
implements java.lang.Comparable

Represents the midnight-to-midnight time period as observed by the AdWords server; this is the finest granularity for representing start and end dates for things like Campaigns and Reports.

This class allows you to specify a start or end date without worrying about issues of time zone or daylight savings time.


Constructor Summary
ReportDate()
          Creates a ReportDate object representing today.
ReportDate(int year, int month, int date)
          Creates a ReportDate object representing the calendar date specified.
 
Method Summary
 int compareTo(java.lang.Object o)
          Natural ordering on ReportDates.
 boolean equals(java.lang.Object obj)
          Returns whether two ReportDates represent the same date.
 int getDate()
          Returns the day of the month.
 int getMonth()
          Returns the month (0 = January, 11 = December).
 int getYear()
          Returns the four digit year.
 int hashCode()
           
 java.util.Calendar toCalendar()
          Returns a Calendar object representing the date specified by this ReportDate.
 java.lang.String toString()
          Returns a string representing the date in the current Locale.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReportDate

public ReportDate()
Creates a ReportDate object representing today.


ReportDate

public ReportDate(int year,
                  int month,
                  int date)
Creates a ReportDate object representing the calendar date specified.

Parameters:
year - the four digit year.
month - the month (0 = January, 11 = December).
date - the day of the specified month.
Throws:
java.lang.IllegalArgumentException - if the arguments do not represent a valid date.
Method Detail

getYear

public int getYear()
Returns the four digit year.


getMonth

public int getMonth()
Returns the month (0 = January, 11 = December).


getDate

public int getDate()
Returns the day of the month.


toCalendar

public java.util.Calendar toCalendar()
Returns a Calendar object representing the date specified by this ReportDate.

Returns:
the Calendar version of this ReportDate.

toString

public java.lang.String toString()
Returns a string representing the date in the current Locale.

Overrides:
toString in class java.lang.Object
Returns:
The date formatted as a String in the default format.

equals

public boolean equals(java.lang.Object obj)
Returns whether two ReportDates represent the same date.

Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
true iff obj is a ReportDate with the same year, month, and date as this.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Natural ordering on ReportDates. A ReportDate is less than another if it represents a date that is earlier, greater than if it represents a date that is later, and equal otherwise.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the ReportDate to compare this to.
Returns:
a negative number if this is earlier than o, 0 if this is equal to o, a positive number otherwise.
Throws:
java.lang.ClassCastException - if o is not a ReportDate.


Copyright © 2005 Google Corp. All Rights Reserved.