|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.api.ads.dfp.lib.utils.DateTimesHelper<T,D>
T - the DateTime typeD - the Date typepublic class DateTimesHelper<T,D>
A utility class for handling DateTime objects.
| Constructor Summary | |
|---|---|
DateTimesHelper(Class<T> dateTimeClass,
Class<D> dateClass)
Constructor. |
|
| Method Summary | |
|---|---|
Calendar |
toCalendar(T dateTime)
Gets a calendar for a DateTime using the default locale,
i.e. |
Calendar |
toCalendar(T dateTime,
Locale locale)
Gets a calendar for a DateTime in the supplied locale. |
T |
toDateTime(Calendar calendar)
Converts a Calendar object to an API date time preserving the
time zone. |
T |
toDateTime(org.joda.time.DateTime dateTime)
Converts a DateTime object to an API date time preserving the
time zone. |
T |
toDateTime(org.joda.time.Instant instant,
String timeZoneId)
Converts an Instant object to an API date time in the time zone
supplied. |
T |
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. |
org.joda.time.DateTime |
toDateTime(T dateTime)
Converts an API date time to a DateTime preserving the time zone. |
String |
toString(T dateTime)
Returns string representation of this date time. |
String |
toStringWithZone(T dateTime,
String newZoneID)
Returns string representation of this date time with a different time zone, preserving the millisecond instant. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DateTimesHelper(Class<T> dateTimeClass,
Class<D> dateClass)
dateTimeClass - the date time classdateClass - the date class| Method Detail |
|---|
public T toDateTime(Calendar calendar)
Calendar object to an API date time preserving the
time zone.
public T toDateTime(org.joda.time.Instant instant,
String timeZoneId)
Instant object to an API date time in the time zone
supplied.
public T toDateTime(org.joda.time.DateTime dateTime)
DateTime object to an API date time preserving the
time zone.
public T toDateTime(String dateTime,
String timeZoneId)
yyyy-MM-dd'T'HH:mm:ss to an API
date time in the time zone supplied.
public org.joda.time.DateTime toDateTime(T dateTime)
DateTime preserving the time zone.
public Calendar toCalendar(T dateTime)
DateTime using the default locale,
i.e. Locale.getDefault().
public Calendar toCalendar(T dateTime,
Locale locale)
DateTime in the supplied locale.
public String toString(T dateTime)
toStringWithZone(Object, String) instead.
dateTime - the date time to stringify
DateTime in
yyyy-MM-dd'T'HH:mm:ss
public String toStringWithZone(T 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 zone
DateTime in
yyyy-MM-dd'T'HH:mm:ss
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||