com.google.api.ads.dfp.axis.utils.v201111
Class Dates

java.lang.Object
  extended by com.google.api.ads.dfp.axis.utils.v201111.Dates

public final class Dates
extends Object

A utility class for handling Date objects.

Author:
Adam Rogal

Field Summary
static String DATE_FORMAT
           
 
Method Summary
static Date fromDate(Date date)
          Creates a Date object from a Java Date object already set to the publisher's timezone.
static Date fromString(String dateString)
          Creates a Date object from a string representation in the form of yyyy-MM-dd (e.g.
static Date toDate(Date date, String timeZoneId)
          Gets a Java Date object from a Date object.
static Date today(String timeZoneId)
          Gets a Date object representing midnight of the present date.
static String toString(Date date, String timeZoneId)
          Gets a string representation of the Date object in the form of yyyy-mm-dd (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final String DATE_FORMAT
See Also:
Constant Field Values
Method Detail

fromString

public static Date fromString(String dateString)
                       throws ParseException
Creates a Date object from a string representation in the form of yyyy-MM-dd (e.g. 2011-01-01).

Parameters:
dateString - the string representation of the Date
Returns:
a Date object created from the string
Throws:
ParseException - if the string could not be parsed

fromDate

public static Date fromDate(Date date)
Creates a Date object from a Java Date object already set to the publisher's timezone.

Parameters:
date - the java.util.Date object to transform into a Date
Returns:
a Date object representing date

today

public static Date today(String timeZoneId)
Gets a Date object representing midnight of the present date.

Returns:
a Date object representing the present date

toDate

public static Date toDate(Date date,
                          String timeZoneId)
Gets a Java Date object from a Date object. The timezone of the Date object is used when creating the new date object.

Parameters:
date - the DFP Date object to convert to a Java Date
timeZoneId - the timezone of the date
Returns:
the DFP Date object as a Java Date in the timezone

toString

public static String toString(Date date,
                              String timeZoneId)
Gets a string representation of the Date object in the form of yyyy-mm-dd (e.g. 2011-01-01)

Parameters:
date - the DateTime object used to create the string
timeZoneId - the timezone of the date
Returns:
a string representation of the Date object


Copyright © 2012. All Rights Reserved.