com.google.api.ads.dfp.axis.utils.v201201
Class DateTimes

java.lang.Object
  extended by com.google.api.ads.dfp.axis.utils.v201201.DateTimes

public final class DateTimes
extends Object

A utility class for handling DateTime objects.

Author:
Adam Rogal

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

Field Detail

DATE_TIME_FORMAT

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

fromString

public static DateTime fromString(String dateTimeString)
                           throws ParseException
Creates a DateTime object from a string representation in the form of yyyy-MM-ddTHH:mm:ss (e.g. 2011-01-01T00:00:00).

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

fromDate

public static DateTime fromDate(Date date)
Creates a DateTime object from a Java Date object already set to the publisher's timezone. The timezone will not be set on the DateTime object as it is ignored as input for all use cases.

Parameters:
date - the Date object to transform into a DateTime
Returns:
a DateTime representing date

now

public static DateTime now(String timeZoneId)
Gets a DateTime object representing the present time in the timezone of the publisher.

Parameters:
timeZoneId - the timezone of the publisher
Returns:
a DateTime object representing the present time in the publisher's timezone

today

public static DateTime today(String timeZoneId)
Gets a DateTime object representing midnight of the present date in the timezone of the publisher (i.e. all time fields are nullified).

Parameters:
timeZoneId - the timezone of the publisher
Returns:
a DateTime object representing the present date in the publisher's timezone

toDate

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

Parameters:
dateTime - the DateTime object to convert to a Date
Returns:
the DateTime object as a Date in the timezone set within dateTime

toString

public static String toString(DateTime dateTime)
Gets a string representation of the DateTime object in the form of yyyy-mm-ddTHH:mm:ss (e.g. 2011-01-01T000:00:00)

Parameters:
dateTime - the DateTime object used to create the string
Returns:
a string representation of the DateTime object


Copyright © 2012. All Rights Reserved.