public final class DateTimes extends Object
DateTime
objects.Modifier and Type | Method and Description |
---|---|
static Calendar |
toCalendar(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
Gets a calendar for a
DateTime using the default locale,
i.e. |
static Calendar |
toCalendar(com.google.api.ads.dfp.axis.v201711.DateTime dateTime,
Locale locale)
Gets a calendar for a
DateTime in the supplied locale. |
static com.google.api.ads.dfp.axis.v201711.DateTime |
toDateTime(Calendar calendar)
Converts a
Calendar object to an API date time preserving the
time zone. |
static com.google.api.ads.dfp.axis.v201711.DateTime |
toDateTime(org.joda.time.DateTime dateTime)
Converts a
DateTime object to an API date time preserving the
time zone. |
static org.joda.time.DateTime |
toDateTime(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
Converts an API date time to a
DateTime preserving the time zone. |
static com.google.api.ads.dfp.axis.v201711.DateTime |
toDateTime(org.joda.time.Instant instant,
String timeZoneId)
Converts an
Instant object to an API date time in the time zone
supplied. |
static com.google.api.ads.dfp.axis.v201711.DateTime |
toDateTime(String dateTime,
String timeZoneId)
Converts a string in the form of
yyyy-MM-dd'T'HH:mm:ss to an API
date time in the time zone supplied. |
static com.google.api.ads.dfp.axis.v201711.DateTime |
toDateTimeWithTimeZone(String dateTime)
Converts a string in the form of
yyyy-MM-dd'T'HH:mm:ss±HH:mm , or
yyyy-MM-dd'T'HH:mm:ssZ for Etc/GMT, to an
API date time in the time zone supplied. |
static String |
toString(com.google.api.ads.dfp.axis.v201711.Date date)
Returns string representation of this date.
|
static String |
toString(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
Returns string representation of this date time.
|
static String |
toStringForTimeZone(com.google.api.ads.dfp.axis.v201711.DateTime dateTime,
String newZoneId)
Returns string representation of this date time with a different time
zone, preserving the millisecond instant.
|
static String |
toStringWithTimeZone(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
Returns string representation of this date time with time zone.
|
public static com.google.api.ads.dfp.axis.v201711.DateTime toDateTime(Calendar calendar)
Calendar
object to an API date time preserving the
time zone.public static com.google.api.ads.dfp.axis.v201711.DateTime toDateTime(org.joda.time.Instant instant, String timeZoneId)
Instant
object to an API date time in the time zone
supplied.public static com.google.api.ads.dfp.axis.v201711.DateTime toDateTime(org.joda.time.DateTime dateTime)
DateTime
object to an API date time preserving the
time zone.public static com.google.api.ads.dfp.axis.v201711.DateTime toDateTime(String dateTime, String timeZoneId)
yyyy-MM-dd'T'HH:mm:ss
to an API
date time in the time zone supplied.public static com.google.api.ads.dfp.axis.v201711.DateTime toDateTimeWithTimeZone(String dateTime)
yyyy-MM-dd'T'HH:mm:ss±HH:mm
, or
yyyy-MM-dd'T'HH:mm:ssZ
for Etc/GMT, to an
API date time in the time zone supplied.public static org.joda.time.DateTime toDateTime(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
DateTime
preserving the time zone.public static Calendar toCalendar(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
DateTime
using the default locale,
i.e. Locale.getDefault().public static Calendar toCalendar(com.google.api.ads.dfp.axis.v201711.DateTime dateTime, Locale locale)
DateTime
in the supplied locale.public static String toString(com.google.api.ads.dfp.axis.v201711.Date date)
date
- the date to stringifyDate
in yyyy-MM-dd
public static String toString(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
toStringForTimeZone(DateTime, String)
instead.dateTime
- the date time to stringifyDateTime
in
yyyy-MM-dd'T'HH:mm:ss
public static String toStringWithTimeZone(com.google.api.ads.dfp.axis.v201711.DateTime dateTime)
toStringForTimeZone(DateTime, String)
instead.dateTime
- the date time to stringifyDateTime
in
yyyy-MM-dd'T'HH:mm:ss±HH:mm
, i.e.
2013-09-013T12:02:03+08:00
or
2013-09-013T12:02:03Z
for Etc/GMT.public static String toStringForTimeZone(com.google.api.ads.dfp.axis.v201711.DateTime dateTime, String newZoneId)
This method is useful for finding the local time in another time zone, especially for filtering.
For example, if this date time holds 12:30 in Europe/London, the result from this method with Europe/Paris would be 13:30. You may also want to use this with your network's time zone, i.e.
String timeZoneId = networkService.getCurrentNetwork().getTimeZone();
String statementPart =
"startDateTime > "
+ DateTimes.toString(apiDateTime, timeZoneId);
//...
statementBuilder.where(statementPart);
This method is in the same style of
DateTime.withZone(org.joda.time.DateTimeZone)
.dateTime
- the date time to stringify into a new time zonenewZoneId
- the time zone ID of the new zoneDateTime
in
yyyy-MM-dd'T'HH:mm:ss
Copyright © 2018. All Rights Reserved.