T - the DateTime typeD - the Date typepublic class DateTimesHelper<T,D> extends Object
DateTime objects.| Constructor and Description |
|---|
DateTimesHelper(Class<T> dateTimeClass,
Class<D> dateClass)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
dateToString(D date)
Returns string representation of this date.
|
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. |
T |
toDateTimeWithTimeZone(String dateTime)
Converts a string in the form of
yyyy-MM-dd'T'HH:mm:ss±HH:mm to an
API date time in the time zone supplied. |
String |
toString(T dateTime)
Returns string representation of this date time.
|
String |
toStringForTimeZone(T dateTime,
String newZoneID)
Returns string representation of this date time with a different time
zone, preserving the millisecond instant.
|
String |
toStringWithTimeZone(T dateTime)
Returns string representation of this date time with time zone.
|
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 T toDateTimeWithTimeZone(String dateTime)
yyyy-MM-dd'T'HH:mm:ss±HH:mm to an
API date time in the time zone supplied.public String dateToString(D date)
date - the date to stringifyDate in yyyy-MM-ddpublic 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)
toStringForTimeZone(Object, String) instead.dateTime - the date time to stringifyDateTime in
yyyy-MM-dd'T'HH:mm:sspublic String toStringWithTimeZone(T dateTime)
toStringForTimeZone(Object, 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:00public String toStringForTimeZone(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 zoneDateTime in
yyyy-MM-dd'T'HH:mm:ssCopyright © 2018. All Rights Reserved.