@Deprecated
public abstract class CalendarUtil
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ECMA_DATE_ONLY_PATTERN
Deprecated.
The
SimpleDateFormat-style pattern for the Javascript / ECMA
date format string when only a pure date without time is to be transferred. |
static java.lang.String |
ECMA_DATE_PATTERN
Deprecated.
The
SimpleDateFormat-style pattern for the Javascript / ECMA
date format string. |
static java.util.TimeZone |
UTC
Deprecated.
Represents the "Etc/UTC" timezone with no offset at all.
|
static java.lang.String |
UTC_ID
Deprecated.
Standard Olson timezone database ID for the UTC timezone.
|
| Constructor and Description |
|---|
CalendarUtil()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
calendarToString(java.util.Calendar cal)
Deprecated.
Safely prints a
Calendar object for debugging output. |
static java.text.SimpleDateFormat |
getEcmaDateFormat(boolean isDate,
java.lang.String timeZoneID)
Deprecated.
Returns a new
SimpleDateFormat that parses and formats date
strings for use with Javascript (ECMA Script) in browsers. |
static java.util.TimeZone |
getTimeZone(java.lang.String tzID)
Deprecated.
Returns a timezone by it's Olson timezone database ID, using the internal
timezone registry instead of the built-in Java timezones
TimeZone.getTimeZone(String). |
static java.util.Calendar |
replaceTimeZone(java.util.Calendar cal,
java.util.TimeZone timeZone)
Deprecated.
Returns a new calendar that has exactly the same date and time parts as
the given original calendar, but with the new timezone.
|
static java.util.Calendar |
shiftTimeZone(java.util.Calendar cal,
java.util.TimeZone timeZone)
Deprecated.
Shifts a calendar into the given timezone.
|
static java.util.Calendar |
shiftToUTC(java.util.Calendar cal)
Deprecated.
Shifts the calendar into the UTC timezone (no timezone offset).
|
public static final java.util.TimeZone UTC
public static final java.lang.String UTC_ID
public static final java.lang.String ECMA_DATE_PATTERN
SimpleDateFormat-style pattern for the Javascript / ECMA
date format string.
Note that this is the variant without commata after weekday and after the date, which seems to be more common.
public static final java.lang.String ECMA_DATE_ONLY_PATTERN
SimpleDateFormat-style pattern for the Javascript / ECMA
date format string when only a pure date without time is to be transferred.public static java.text.SimpleDateFormat getEcmaDateFormat(boolean isDate,
java.lang.String timeZoneID)
SimpleDateFormat that parses and formats date
strings for use with Javascript (ECMA Script) in browsers. The output can
be used in new Date(string) in Javascript. An example ECMA date
string is: Wed Aug 27 2008 23:59:59 GMT+0200.
When isDate == true, the format will only print the date part and
not include the time and timezone parts. For example: Wed Aug 27
2008.
The timeZoneID can be optionally given to denote the timezone in
which the string should be formatted. For example, an UTC date such as
Wed Aug 27 2008 10:00:00 GMT+0000 will result in:
Wed Aug 27 2008 05:00:00 GMT-0500 for a timezone with -5h offset, eg. "America/New_York"Wed Aug 27 2008 11:00:00 GMT+0100 for a timezone with +1h offset, eg. "Europe/Berlin"timeZoneID == null, the UTC timezone will be used. When
isDate == true, it will be ignored.
The locale used will always be US as that seems to be the string format
that all browsers can parse with new Date(string). The
patterns used are ECMA_DATE_PATTERN and
ECMA_DATE_ONLY_PATTERN (when isDate == true).
isDate - whether only the date part should be formattedtimeZoneID - a time zone ID such as "Europe/Berlin" (optional, can be
null, in which case UTC is used; ignored when isDate == true)SimpleDateFormat for the ECMA date formatpublic static java.util.TimeZone getTimeZone(java.lang.String tzID)
TimeZone.getTimeZone(String).tzID - timezone ID, eg. "Europe/Berlin"TimeZone object or null if the id was not
found or was nullpublic static java.util.Calendar shiftTimeZone(java.util.Calendar cal,
java.util.TimeZone timeZone)
Calendar.setTimeZone(TimeZone).
For example, a date like 2009-08-10 12:00 +02:00 with a target timezone
-02:00 would result in 2009-08-10 08:00 -02:00.
cal - input date in another timezonetimeZone - target timezonepublic static java.util.Calendar shiftToUTC(java.util.Calendar cal)
shiftTimeZone(Calendar, TimeZone) with the
"Etc/UTC" timezone.
For example, a date like 2009-08-10 12:00 +02:00 would
result in 2009-08-10 10:00 +00:00.
cal - input date in another timezonepublic static java.util.Calendar replaceTimeZone(java.util.Calendar cal,
java.util.TimeZone timeZone)
shiftTimeZone(Calendar, TimeZone) or
Calendar.setTimeZone(java.util.TimeZone) would do, but instead
replaces it. This keeps the date and time parts the same, and effectively
changes the UTC millis.
For example, a date like 2009-08-10 12:00 +02:00 with a target timezone
-02:00 would result in 2009-08-10 12:00 -02:00.
cal - input datetimeZone - target timezonepublic static java.lang.String calendarToString(java.util.Calendar cal)
Calendar object for debugging output. Shows only
the important fields and is much more readable than the standard
Calendar.toString() output.