Java org.apache.commons.lang.time DateUtils fields, constructors, methods, implement or subclass

Example usage for Java org.apache.commons.lang.time DateUtils fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for org.apache.commons.lang.time DateUtils.

The text is from its open source code.

Subclass

org.apache.commons.lang.time.DateUtils has subclasses.
Click this link to see all its subclasses.

Field

longMILLIS_PER_SECOND
Number of milliseconds in a standard second.
longMILLIS_PER_MINUTE
Number of milliseconds in a standard minute.
longMILLIS_PER_HOUR
Number of milliseconds in a standard hour.
longMILLIS_PER_DAY
Number of milliseconds in a standard day.
intSEMI_MONTH
This is half a month, so this represents whether a date is in the top or bottom half of the month.
intRANGE_WEEK_SUNDAY
A week range, starting on Sunday.
intRANGE_WEEK_MONDAY
A week range, starting on Monday.
intRANGE_WEEK_RELATIVE
A week range, starting on the day focused.

Constructor

DateUtils()

DateUtils instances should NOT be constructed in standard programming.

Method

Dateadd(Date date, int calendarField, int amount)
Adds to a date returning a new object.
DateaddDays(Date date, int amount)
Adds a number of days to a date returning a new object.
DateaddHours(Date date, int amount)
Adds a number of hours to a date returning a new object.
DateaddMilliseconds(Date date, int amount)
Adds a number of milliseconds to a date returning a new object.
DateaddMinutes(Date date, int amount)
Adds a number of minutes to a date returning a new object.
DateaddMonths(Date date, int amount)
Adds a number of months to a date returning a new object.
DateaddSeconds(Date date, int amount)
Adds a number of seconds to a date returning a new object.
DateaddWeeks(Date date, int amount)
Adds a number of weeks to a date returning a new object.
DateaddYears(Date date, int amount)
Adds a number of years to a date returning a new object.
Dateceiling(Date date, int field)

Ceil this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 14:00:00.000.

Calendarceiling(Calendar date, int field)

Ceil this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000.

Dateceiling(Object date, int field)

Ceil this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000.

longgetFragmentInDays(Date date, int fragment)

Returns the number of days within the fragment.

longgetFragmentInDays(Calendar calendar, int fragment)

Returns the number of days within the fragment.

longgetFragmentInHours(Date date, int fragment)

Returns the number of hours within the fragment.

longgetFragmentInHours(Calendar calendar, int fragment)

Returns the number of hours within the fragment.

longgetFragmentInMinutes(Date date, int fragment)

Returns the number of minutes within the fragment.

longgetFragmentInMinutes(Calendar calendar, int fragment)

Returns the number of minutes within the fragment.

booleanisSameDay(Date date1, Date date2)

Checks if two date objects are on the same day ignoring time.

28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.

booleanisSameDay(Calendar cal1, Calendar cal2)

Checks if two calendar objects are on the same day ignoring time.

28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true.

booleanisSameInstant(Date date1, Date date2)

Checks if two date objects represent the same instant in time.

This method compares the long millisecond time of the two objects.

booleanisSameInstant(Calendar cal1, Calendar cal2)

Checks if two calendar objects represent the same instant in time.

This method compares the long millisecond time of the two objects.

Iteratoriterator(Date focus, int rangeStyle)

This constructs an Iterator over each day in a date range defined by a focus date and range style.

For instance, passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return an Iterator that starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002, returning a Calendar instance for each intermediate day.

This method provides an iterator that returns Calendar objects.

Iteratoriterator(Calendar focus, int rangeStyle)

This constructs an Iterator over each day in a date range defined by a focus date and range style.

For instance, passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return an Iterator that starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002, returning a Calendar instance for each intermediate day.

This method provides an iterator that returns Calendar objects.

Iteratoriterator(Object focus, int rangeStyle)

This constructs an Iterator over each day in a date range defined by a focus date and range style.

For instance, passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return an Iterator that starts with Sunday, June 30, 2002 and ends with Saturday, August 3, 2002, returning a Calendar instance for each intermediate day.

DateparseDate(String str, String... parsePatterns)

Parses a string representing a date by trying a variety of different parsers.

The parse will try each parse pattern in turn.

DateparseDateStrictly(String str, String... parsePatterns)

Parses a string representing a date by trying a variety of different parsers.

The parse will try each parse pattern in turn.

Dateround(Date date, int field)

Round this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this was passed with HOUR, it would return 28 Mar 2002 14:00:00.000.

Calendarround(Calendar date, int field)

Round this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this was passed with HOUR, it would return 28 Mar 2002 14:00:00.000.

Dateround(Object date, int field)

Round this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if this was passed with HOUR, it would return 28 Mar 2002 14:00:00.000.

DatesetDays(Date date, int amount)
Sets the day of month field to a date returning a new object.
DatesetHours(Date date, int amount)
Sets the hours field to a date returning a new object.
DatesetMilliseconds(Date date, int amount)
Sets the miliseconds field to a date returning a new object.
DatesetMinutes(Date date, int amount)
Sets the minute field to a date returning a new object.
DatesetMonths(Date date, int amount)
Sets the months field to a date returning a new object.
DatesetSeconds(Date date, int amount)
Sets the seconds field to a date returning a new object.
DatesetYears(Date date, int amount)
Sets the years field to a date returning a new object.
CalendartoCalendar(Date date)
Convert a Date into a Calendar .
Datetruncate(Date date, int field)

Truncate this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000.

Calendartruncate(Calendar date, int field)

Truncate this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000.

Datetruncate(Object date, int field)

Truncate this date, leaving the field specified as the most significant field.

For example, if you had the datetime of 28 Mar 2002 13:45:01.231, if you passed with HOUR, it would return 28 Mar 2002 13:00:00.000.

inttruncatedCompareTo(Calendar cal1, Calendar cal2, int field)
Determines how two calendars compare up to no more than the specified most significant field.
inttruncatedCompareTo(Date date1, Date date2, int field)
Determines how two dates compare up to no more than the specified most significant field.