net.fortuna.ical4j.util
Class Dates

java.lang.Object
  extended bynet.fortuna.ical4j.util.Dates

public final class Dates
extends Object

Implements a collection of utility methods relevant to date processing.

Author:
Ben Fortuna

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(Date date, int monthDay)
          Returns the absolute month day for the month specified by the supplied date.
static int getAbsWeekNo(Date date, int weekNo)
          Returns the absolute week number for the year specified by the supplied date.
static int getAbsYearDay(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(Date date, Value type)
          Returns a new date instance of the specified type.
static long round(long time, int precision)
          Rounds a time value to remove any precision smaller than specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLIS_PER_SECOND

public static final long MILLIS_PER_SECOND
See Also:
Constant Field Values

MILLIS_PER_MINUTE

public static final long MILLIS_PER_MINUTE
See Also:
Constant Field Values

MILLIS_PER_HOUR

public static final long MILLIS_PER_HOUR
See Also:
Constant Field Values

MILLIS_PER_DAY

public static final long MILLIS_PER_DAY
See Also:
Constant Field Values

MILLIS_PER_WEEK

public static final long MILLIS_PER_WEEK
See Also:
Constant Field Values

DAYS_PER_WEEK

public static final int DAYS_PER_WEEK
See Also:
Constant Field Values

PRECISION_SECOND

public static final int PRECISION_SECOND
See Also:
Constant Field Values

PRECISION_DAY

public static final int PRECISION_DAY
See Also:
Constant Field Values
Method Detail

getAbsWeekNo

public static int getAbsWeekNo(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(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:

getAbsMonthDay

public static int getAbsMonthDay(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:

getInstance

public static Date getInstance(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

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

round

public static final long round(long time,
                               int precision)
Rounds a time value to remove any precision smaller than specified.

Parameters:
time - the time value to round
Returns:
a round time value