com.funambol.common.pim.vcalendar
Class CalendarUtils

java.lang.Object
  extended by com.funambol.common.pim.vcalendar.CalendarUtils

public class CalendarUtils
extends java.lang.Object

A set of Calendar utility methods


Field Summary
static long DAY_FACTOR
           
static long HOUR_FACTOR
           
static long MINUTE_FACTOR
           
static java.lang.String PATTERN_UTC
           
static int PATTERN_UTC_LENGTH
           
static java.lang.String PATTERN_UTC_WOZ
           
static int PATTERN_UTC_WOZ_LENGTH
           
static java.lang.String PATTERN_YYYY_MM_DD
           
static int PATTERN_YYYY_MM_DD_LENGTH
           
static java.lang.String PATTERN_YYYYMMDD
           
static int PATTERN_YYYYMMDD_LENGTH
           
static long SECOND_FACTOR
           
static long UNDEFINED_TIME
           
 
Constructor Summary
CalendarUtils()
           
 
Method Summary
static long adjustTimeFromDefaultTimezone(long time)
          Shift the time from the local timezone do UTC
static long adjustTimeToDefaultTimezone(long time)
          Shift the time from UTC to the local timezone
static java.lang.String formatDateTime(long milliseconds, boolean allday, java.lang.String tzid)
          Format a DateTime String from the specified time in milliseconds, and the specific timezone id.
static java.lang.String formatDateTime(long milliseconds, boolean allday, java.lang.String tz, java.util.Vector daylight)
          Format a DateTime String from the specified time in milliseconds, and the specific timezone offset and daylight.
static long getDefaultTimeZoneOffset()
          Get the offset between GMT and the local timezone
static java.lang.String getFullInt(int value, int digits)
          Fill a number String with '0' chars
static long getLocalDateTime(java.lang.String value, java.lang.String tzid)
          Get the local time from DATE/DATE-TIME value, starting from the specified timezone id.
protected static long getTimezoneOffset(java.lang.String tzinfo)
           
static long getTimeZoneOffset(java.util.TimeZone zn)
          Get the offset between GMT and the specified timezone
protected static long getUnsignedTimezoneOffset(java.lang.String tzinfo)
           
static java.util.Calendar parseDate(java.lang.String field, java.util.TimeZone tz)
          Get time (a long value that holds the number of milliseconds since midnight GMT, January 1, 1970) from date in "yyyy-MM-dd" String format
static java.util.Calendar parseDateTime(java.lang.String data, java.lang.String tz, java.util.Vector daylights)
          Get time from date in "yyyyMMddTHHmmssZ" or "yyyyMMdd" or "yyyyMMddTHHmmss" format.
static java.util.Calendar parseDateTime(java.lang.String data, java.util.TimeZone tz)
          Get time from date in "yyyyMMddTHHmmssZ" or "yyyyMMdd" or "yyyyMMddTHHmmss"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECOND_FACTOR

public static final long SECOND_FACTOR
See Also:
Constant Field Values

MINUTE_FACTOR

public static final long MINUTE_FACTOR
See Also:
Constant Field Values

HOUR_FACTOR

public static final long HOUR_FACTOR
See Also:
Constant Field Values

DAY_FACTOR

public static final long DAY_FACTOR
See Also:
Constant Field Values

PATTERN_YYYYMMDD

public static final java.lang.String PATTERN_YYYYMMDD
See Also:
Constant Field Values

PATTERN_YYYYMMDD_LENGTH

public static final int PATTERN_YYYYMMDD_LENGTH
See Also:
Constant Field Values

PATTERN_YYYY_MM_DD

public static final java.lang.String PATTERN_YYYY_MM_DD
See Also:
Constant Field Values

PATTERN_YYYY_MM_DD_LENGTH

public static final int PATTERN_YYYY_MM_DD_LENGTH
See Also:
Constant Field Values

PATTERN_UTC

public static final java.lang.String PATTERN_UTC
See Also:
Constant Field Values

PATTERN_UTC_LENGTH

public static final int PATTERN_UTC_LENGTH
See Also:
Constant Field Values

PATTERN_UTC_WOZ

public static final java.lang.String PATTERN_UTC_WOZ
See Also:
Constant Field Values

PATTERN_UTC_WOZ_LENGTH

public static final int PATTERN_UTC_WOZ_LENGTH
See Also:
Constant Field Values

UNDEFINED_TIME

public static final long UNDEFINED_TIME
See Also:
Constant Field Values
Constructor Detail

CalendarUtils

public CalendarUtils()
Method Detail

getLocalDateTime

public static long getLocalDateTime(java.lang.String value,
                                    java.lang.String tzid)
Get the local time from DATE/DATE-TIME value, starting from the specified timezone id. If the tzid is not specified (is null) set the timezone to UTC only if the time value is in UTC format (e.g. ends with 'Z'). If the timezone id is specified, try to get the corresponding timezone, if not successfull get the device default timezone.

Parameters:
value -
tzid -
Returns:

adjustTimeToDefaultTimezone

public static long adjustTimeToDefaultTimezone(long time)
Shift the time from UTC to the local timezone

Parameters:
time -
Returns:

adjustTimeFromDefaultTimezone

public static long adjustTimeFromDefaultTimezone(long time)
Shift the time from the local timezone do UTC

Parameters:
time -
Returns:

parseDate

public static java.util.Calendar parseDate(java.lang.String field,
                                           java.util.TimeZone tz)
Get time (a long value that holds the number of milliseconds since midnight GMT, January 1, 1970) from date in "yyyy-MM-dd" String format

Parameters:
field - Date in "yyyy-MM-dd" String format
Returns:
time at 00:00:00 from date

parseDateTime

public static java.util.Calendar parseDateTime(java.lang.String data,
                                               java.util.TimeZone tz)
Get time from date in "yyyyMMddTHHmmssZ" or "yyyyMMdd" or "yyyyMMddTHHmmss"

Parameters:
data - The data to parse
tz - The timezone
Returns:
The Calendar object set to the specific date-time

parseDateTime

public static java.util.Calendar parseDateTime(java.lang.String data,
                                               java.lang.String tz,
                                               java.util.Vector daylights)
Get time from date in "yyyyMMddTHHmmssZ" or "yyyyMMdd" or "yyyyMMddTHHmmss" format.

Parameters:
data - The data to parse
tz - The timezone offset String in the ISO 8601 format.
daylights - The Vector containing a list of daylights.
Returns:
The Calendar object set to the specific date-time

getTimezoneOffset

protected static long getTimezoneOffset(java.lang.String tzinfo)

getUnsignedTimezoneOffset

protected static long getUnsignedTimezoneOffset(java.lang.String tzinfo)

formatDateTime

public static java.lang.String formatDateTime(long milliseconds,
                                              boolean allday,
                                              java.lang.String tz,
                                              java.util.Vector daylight)
Format a DateTime String from the specified time in milliseconds, and the specific timezone offset and daylight. If it's an allday time format as "yyyyMMdd", format as "yyyyMMddTHHmmss(Z)" otherwise.

Parameters:
milliseconds -
allday -
tz -
daylight -
Returns:

formatDateTime

public static java.lang.String formatDateTime(long milliseconds,
                                              boolean allday,
                                              java.lang.String tzid)
Format a DateTime String from the specified time in milliseconds, and the specific timezone id. If it's an allday time format as "yyyyMMdd", format as "yyyyMMddTHHmmss(Z)" otherwise.

Parameters:
milliseconds -
allday -
tzid -
Returns:

getFullInt

public static java.lang.String getFullInt(int value,
                                          int digits)
Fill a number String with '0' chars

Parameters:
value -
digits -
Returns:

getDefaultTimeZoneOffset

public static long getDefaultTimeZoneOffset()
Get the offset between GMT and the local timezone

Returns:
the offset

getTimeZoneOffset

public static long getTimeZoneOffset(java.util.TimeZone zn)
Get the offset between GMT and the specified timezone

Returns:
the offset


Copyright © 2001-2009 Funambol.