net.fortuna.ical4j.util

Class Dates


public final class Dates
extends java.lang.Object

$Id: Dates.java,v 1.9 2008/12/16 12:34:53 fortuna Exp $ Created on 26/06/2005 Implements a collection of utility methods relevant to date processing.

Field Summary

static int
DAYS_PER_WEEK
static long
MILLIS_PER_DAY
static long
MILLIS_PER_HOUR
static long
MILLIS_PER_MINUTE
static long
MILLIS_PER_SECOND
static long
MILLIS_PER_WEEK
static int
PRECISION_DAY
static int
PRECISION_SECOND

Method Summary

static int
getAbsMonthDay(java.util.Date date, int monthDay)
Returns the absolute month day for the month specified by the supplied date.
static int
getAbsWeekNo(java.util.Date date, int weekNo)
Returns the absolute week number for the year specified by the supplied date.
static int
getAbsYearDay(java.util.Date date, int yearDay)
Returns the absolute year day for the year specified by the supplied date.
static Calendar
getCalendarInstance(Date date)
Returns an instance of java.util.Calendar that is suitably initialised for working with the specified date.
static Date
getInstance(java.util.Date date, Value type)
Returns a new date instance of the specified type.
static long
round(long time, int precision)
static long
round(long time, int precision, TimeZone tz)
Rounds a time value to remove any precision smaller than specified.

Field Details

DAYS_PER_WEEK

public static final int DAYS_PER_WEEK
Field Value:
7

MILLIS_PER_DAY

public static final long MILLIS_PER_DAY
Field Value:
86400000L

MILLIS_PER_HOUR

public static final long MILLIS_PER_HOUR
Field Value:
3600000L

MILLIS_PER_MINUTE

public static final long MILLIS_PER_MINUTE
Field Value:
60000L

MILLIS_PER_SECOND

public static final long MILLIS_PER_SECOND
Field Value:
1000L

MILLIS_PER_WEEK

public static final long MILLIS_PER_WEEK
Field Value:
604800000L

PRECISION_DAY

public static final int PRECISION_DAY
Field Value:
1

PRECISION_SECOND

public static final int PRECISION_SECOND
Field Value:
0

Method Details

getAbsMonthDay

public static int getAbsMonthDay(java.util.Date date,
                                 int monthDay)
Returns the absolute month day for the month specified by the supplied date. Note that a value of zero (0) is invalid for the monthDay parameter and an IllegalArgumentException will be thrown.
Parameters:
date -
monthDay -
Returns:

getAbsWeekNo

public static int getAbsWeekNo(java.util.Date date,
                               int weekNo)
Returns the absolute week number for the year specified by the supplied date. Note that a value of zero (0) is invalid for the weekNo parameter and an IllegalArgumentException will be thrown.
Parameters:
date -
weekNo -
Returns:

getAbsYearDay

public static int getAbsYearDay(java.util.Date date,
                                int yearDay)
Returns the absolute year day for the year specified by the supplied date. Note that a value of zero (0) is invalid for the yearDay parameter and an IllegalArgumentException will be thrown.
Parameters:
date -
yearDay -
Returns:

getCalendarInstance

public static Calendar getCalendarInstance(Date date)
Returns an instance of java.util.Calendar that is suitably initialised for working with the specified date.
Parameters:
date - a date instance
Returns:
a java.util.Calendar

getInstance

public static Date getInstance(java.util.Date date,
                               Value type)
Returns a new date instance of the specified type. If no type is specified a DateTime instance is returned.
Parameters:
date - a seed Java date instance
type - the type of date instance
Returns:
an instance of net.fortuna.ical4j.model.Date

round

public static long round(long time,
                         int precision)
Parameters:
time -
precision -
Returns:

round

public static long round(long time,
                         int precision,
                         TimeZone tz)
Rounds a time value to remove any precision smaller than specified.
Parameters:
time - the time value to round
Returns:
a round time value