Top Description Fields Constructors Methods
net.fortuna.ical4j.util

public final Class Dates

extends Object
Class Inheritance
Annotations
@Deprecated
Imports
net.fortuna.ical4j.model.Date, .DateTime, net.fortuna.ical4j.model.parameter.Value, java.text.MessageFormat, java.util.ArrayList, .Calendar, .List, .TimeZone

Deprecated

Utility class for old date/time API no longer required

$Id$ Created on 26/06/2005 Implements a collection of utility methods relevant to date processing.
Author
Ben Fortuna

Field Summary

Modifier and TypeField and Description
public static final int
DAYS_PER_WEEK

Number of days in one week.

private static final String
private static final String
private static final String
public static final int
MAX_DAYS_PER_MONTH

Maximum number of days per month.

public static final int
MAX_DAYS_PER_YEAR

Maximum number of days per year.

public static final int
MAX_WEEKS_PER_YEAR

Maximum number of weeks per year.

public static final long
MILLIS_PER_DAY

Number of milliseconds in one day.

public static final long
MILLIS_PER_HOUR

Number of milliseconds in one hour.

public static final long
MILLIS_PER_MINUTE

Number of milliseconds in one minute.

public static final long
MILLIS_PER_SECOND

Number of milliseconds in one second.

public static final long
MILLIS_PER_WEEK

Number of milliseconds in one week.

public static final int
PRECISION_DAY

Constant indicating precision to the day.

public static final int
PRECISION_SECOND

Constant indicating precision to the second.

Constructor Summary

AccessConstructor and Description
private
Dates()

Constructor made private to prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
public static int

Returns:

the absolute day of month for the specified offset
getAbsMonthDay
(final Date
a date instance representing a day of the month
date
,
final int
a day of month offset
monthDay
)

Returns the absolute month day for the month specified by the supplied date.

public static int

Returns:

the absolute week of the year for the specified offset
getAbsWeekNo
(final Date
a date instance representing a week of the year
date
,
final int
a week number offset
weekNo
)

Returns the absolute week number for the year specified by the supplied date.

public static int

Returns:

the absolute day of month for the specified offset
getAbsYearDay
(final Date
a date instance representing a day of the year
date
,
final int
a day of year offset
yearDay
)

Returns the absolute year day for the year specified by the supplied date.

public static Calendar

Returns:

a java.util.Calendar
getCalendarInstance
(final Date
a date instance
date
)
References Deprecated Date is deprecated or references (maybe indirectly) at least one deprecated element.

Returns an instance of java.util.Calendar that is suitably initialised for working with the specified date.

public static long

Returns:

the current time in millisec.
getCurrentTimeRounded
()

Returns the System.currentTimeMillis(), rounded to the second.

public static Date

Returns:

an instance of net.fortuna.ical4j.model.Date
getInstance
(final Date
a seed Java date instance
date
,
final Value
the type of date instance
type
)
References Deprecated Date is deprecated or references (maybe indirectly) at least one deprecated element.

Returns a new date instance of the specified type.

public static long

Returns:

a round time value
round
(final long
the time value to round
time
,
final int
the rounding precision
precision
)
Deprecated It is not all that useful to perform rounding without specifying an explicit timezone.

public static long

Returns:

a round time value
round
(final long
the time value to round
time
,
final int
the rounding precision
precision
,
final TimeZone
the timezone of the rounded value
tz
)

Rounds a time value to remove any precision smaller than specified.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DAYS_PER_WEEKback to summary
public static final int DAYS_PER_WEEK

Number of days in one week.

INVALID_MONTH_DAY_MESSAGEback to summary
private static final String INVALID_MONTH_DAY_MESSAGE
INVALID_WEEK_MESSAGEback to summary
private static final String INVALID_WEEK_MESSAGE
INVALID_YEAR_DAY_MESSAGEback to summary
private static final String INVALID_YEAR_DAY_MESSAGE
MAX_DAYS_PER_MONTHback to summary
public static final int MAX_DAYS_PER_MONTH

Maximum number of days per month.

MAX_DAYS_PER_YEARback to summary
public static final int MAX_DAYS_PER_YEAR

Maximum number of days per year.

MAX_WEEKS_PER_YEARback to summary
public static final int MAX_WEEKS_PER_YEAR

Maximum number of weeks per year.

MILLIS_PER_DAYback to summary
public static final long MILLIS_PER_DAY

Number of milliseconds in one day.

MILLIS_PER_HOURback to summary
public static final long MILLIS_PER_HOUR

Number of milliseconds in one hour.

MILLIS_PER_MINUTEback to summary
public static final long MILLIS_PER_MINUTE

Number of milliseconds in one minute.

MILLIS_PER_SECONDback to summary
public static final long MILLIS_PER_SECOND

Number of milliseconds in one second.

MILLIS_PER_WEEKback to summary
public static final long MILLIS_PER_WEEK

Number of milliseconds in one week.

PRECISION_DAYback to summary
public static final int PRECISION_DAY

Constant indicating precision to the day.

PRECISION_SECONDback to summary
public static final int PRECISION_SECOND

Constant indicating precision to the second.

Constructor Detail

Datesback to summary
private Dates()

Constructor made private to prevent instantiation.

Method Detail

getAbsMonthDayback to summary
public static int getAbsMonthDay(final Date date, final 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:Date

a date instance representing a day of the month

monthDay:int

a day of month offset

Returns:int

the absolute day of month for the specified offset

getAbsWeekNoback to summary
public static int getAbsWeekNo(final Date date, final 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:Date

a date instance representing a week of the year

weekNo:int

a week number offset

Returns:int

the absolute week of the year for the specified offset

getAbsYearDayback to summary
public static int getAbsYearDay(final Date date, final 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:Date

a date instance representing a day of the year

yearDay:int

a day of year offset

Returns:int

the absolute day of month for the specified offset

getCalendarInstanceback to summary
public static Calendar getCalendarInstance(final Date date)

References Deprecated

Date is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns an instance of java.util.Calendar that is suitably initialised for working with the specified date.

Parameters
date:Date

a date instance

Returns:Calendar

a java.util.Calendar

getCurrentTimeRoundedback to summary
public static long getCurrentTimeRounded()

Returns the System.currentTimeMillis(), rounded to the second.

By doing a rough rounding here, we avoid an expensive java.util.Calendar based rounding later on.

Returns:long

the current time in millisec.

getInstanceback to summary
public static Date getInstance(final Date date, final Value type)

References Deprecated

Date is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Returns a new date instance of the specified type. If no type is specified a DateTime instance is returned.

Parameters
date:Date

a seed Java date instance

type:Value

the type of date instance

Returns:Date

an instance of net.fortuna.ical4j.model.Date

roundback to summary
public static long round(final long time, final int precision)

Deprecated

It is not all that useful to perform rounding without specifying an explicit timezone.

Parameters
time:long

the time value to round

precision:int

the rounding precision

Returns:long

a round time value

Annotations
@Deprecated
roundback to summary
public static long round(final long time, final int precision, final TimeZone tz)

Rounds a time value to remove any precision smaller than specified.

Parameters
time:long

the time value to round

precision:int

the rounding precision

tz:TimeZone

the timezone of the rounded value

Returns:long

a round time value