java.lang.Object | |
↳ | com.atlassian.core.util.DateUtils |
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DateUtils.DateRange | |||||||||||
DateUtils.Duration |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | AM | ||||||||||
String | PM |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DAY_MILLIS | |||||||||||
HOUR_MILLIS | |||||||||||
ISO8601DateFormat | Date Format to be used for internal logging operations | ||||||||||
MINUTE_MILLIS | |||||||||||
MONTH_MILLIS | |||||||||||
SECOND_MILLIS | |||||||||||
YEAR_MILLIS |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Resolution is the degree of difference.
| |||||||||||
compares if these two timestamps are within 10 milliseconds of each other (precision error)
| |||||||||||
This is used by the Velocity templates as a bean
| |||||||||||
This is used by the Velocity templates as a bean
| |||||||||||
This method is deprecated.
You should be calling formatDurationPretty
| |||||||||||
Given a duration string, get the number of seconds it represents (all case insensitive):
| |||||||||||
This function retrieves a duration in seconds that depends on number of hours in a day and
days in a week
| |||||||||||
Given a duration string, get the number of seconds it represents (all case insensitive):
| |||||||||||
This function retrieves a duration in seconds that depends on number of hours in a day and
days in a week.
| |||||||||||
Converts a number of seconds into a pretty formatted data string.
| |||||||||||
Converts a number of seconds into a pretty formatted data string.
| |||||||||||
Get a pretty formatted duration for the given number of seconds.
| |||||||||||
Converts a number of seconds into a pretty formatted data string.
| |||||||||||
Converts a number of seconds into a pretty formatted data string.
| |||||||||||
Convert a duration string in the number of seconds it represents.
| |||||||||||
Get String representation of a duration
| |||||||||||
Get a duration string representing the given number of seconds.
| |||||||||||
Get a duration string representing the given number of seconds.
| |||||||||||
Get String representation of a (possibly negative) duration.
| |||||||||||
Get a duration string with the possibility of a negative.
| |||||||||||
Given a period, and a date that falls within that period, create a range of dates such
that the period is contained exactly within [startDate
| |||||||||||
Change the date of a Calendar object so that it has the maximum resolution
of "period" where period is one of the constants in CALENDAR_PERIODS above.
| |||||||||||
Change the date of a Calendar object so that it has the minimum resolution
of "period" where period is one of the constants in CALENDAR_PERIODS above.
| |||||||||||
Check whether a given duration string is valid
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Date Format to be used for internal logging operations
Resolution is the degree of difference.
0 = months 1 = days 2 = hours 3 = minutes 4 = secondsdateA | first date to compare |
---|---|
dateB | second date to compare |
resolution | the degree of difference |
resourceBundle | contains localizations for core.dateutils strings |
compares if these two timestamps are within 10 milliseconds of each other (precision error)
t1 | first timestamp to compare |
---|---|
t2 | second timestamp to compare |
This is used by the Velocity templates as a bean
seconds | duration as a string |
---|
This is used by the Velocity templates as a bean
l | a duration in seconds |
---|
This method is deprecated.
You should be calling formatDurationPretty
This is used by the WebWork tags as a bean Despite the name it doesn't actually format a duration string. It takes a long.
l | a duration in seconds |
---|
Given a duration string, get the number of seconds it represents (all case insensitive):
durationStr | the duration string |
---|
InvalidDurationException | if the duration is invalid |
---|
This function retrieves a duration in seconds that depends on number of hours in a day and days in a week
durationStr | to convert to a duration |
---|---|
hoursPerDay | Number of hourse i day |
daysPerWeek | Days Per Week |
defaultUnit | the unit used when one is not specified on a measure in the durationStr |
InvalidDurationException | if its badly formatted duration |
---|
Given a duration string, get the number of seconds it represents (all case insensitive):
durationStr | the duration string |
---|---|
defaultUnit | the unit used when another is not specified in the durationStr |
InvalidDurationException | if the duration is invalid |
---|
This function retrieves a duration in seconds that depends on number of hours in a day and days in a week. The default unit is MINUTE (i.e. "2" == "2 minutes")
durationStr | to convert to a duration |
---|---|
hoursPerDay | Number of hourse i day |
daysPerWeek | Days Per Week |
InvalidDurationException | if its badly formatted duration |
---|
Converts a number of seconds into a pretty formatted data string. The resolution is in minutes. So if the number of seconds is greater than a minute, it will only be shown down top minute resolution. If the number of seconds is less than a minute it will be shown in seconds.
So for example76
becomes '1 minute'
, while 42
becomes '42 seconds'
numSecs | the number of seconds in the duration |
---|---|
resourceBundle | a resouce bundle for i18n |
Converts a number of seconds into a pretty formatted data string. The resolution is in minutes. So if the number of seconds is greater than a minute, it will only be shown down top minute resolution. If the number of seconds is less than a minute it will be shown in seconds.
So for example76
becomes '1 minute'
, while 42
becomes '42 seconds'
numSecs | the number of seconds in the duration |
---|---|
hoursPerDay | the hours in a day |
daysPerWeek | the number of days in a week |
resourceBundle | a resouce bundle for i18n |
Get a pretty formatted duration for the given number of seconds. (e.g. "4 days, 2 hours, 30 minutes")
numSecs | the number of seconds in the duration |
---|---|
secondsPerDay | the number of seconds in a "day" |
secondsPerWeek | the number of seconds in a "week" |
resourceBundle | the bundle containing translations for the strings used in the pretty string (e.g. "days") |
Converts a number of seconds into a pretty formatted data string. The resolution is in seconds.
So for example76
becomes '1 minute, 16 seconds'
, while 42
becomes '42 seconds'
numSecs | the number of seconds in the duration |
---|---|
hoursPerDay | the hours in a day |
daysPerWeek | the number of days in a week |
resourceBundle | a resouce bundle for i18n |
Converts a number of seconds into a pretty formatted data string. The resolution is in seconds.
So for example76
becomes '1 minute, 16 seconds'
, while 42
becomes '42 seconds'
numSecs | the number of seconds in the duration |
---|---|
resourceBundle | a resouce bundle for i18n |
Convert a duration string in the number of seconds it represents. This method takes seconds per day and seconds per weeks instead of "hours per day" or "days per week" because we may want a non-integral number of hours per day.
durationStr | the duration string |
---|---|
secondsPerDay | number of seconds in a working "day" (e.g. could be equal 6.5 hours) |
secondsPerWeek | number of seconds in a working "week" (e.g. could be equal to 4.5 days) |
defaultUnit | the unit to use for numbers with no unit specified (e.g. "12") |
InvalidDurationException | if the duration string cannot be parsed |
---|
Get String representation of a duration
seconds | Number of seconds |
---|
Get a duration string representing the given number of seconds. The string will use the largest unit possible. (i.e. 1w 3d)
l | the number of seconds |
---|---|
hoursPerDay | hours in a working day |
daysPerWeek | days in a working week |
Get a duration string representing the given number of seconds. The string will use the largest unit possible. (i.e. 1w 3d). Use this method when you want to specify a non-integral number of hours in a day (e.g. 7.5) or days per week.
l | the number of seconds |
---|---|
secondsPerDay | the number of seconds in a working day |
secondsPerWeek | the number of seconds in a working week |
Get String representation of a (possibly negative) duration.
seconds | Number of seconds |
---|
Get a duration string with the possibility of a negative.
A duration will be considered negative if the first non-space character is a - sign.durationStr | the duration string |
---|
InvalidDurationException | if its a badly formatted duration |
---|
Given a period, and a date that falls within that period, create a range of dates such that the period is contained exactly within [startDate
date | a calendar object of a date falling in that range |
---|---|
period | something in CALENDAR_PERIODS |
Change the date of a Calendar object so that it has the maximum resolution of "period" where period is one of the constants in CALENDAR_PERIODS above.
e.g. to obtain the maximum value for a month, call toEndOfPeriod(calendarObject, Calendar.MONTH)calendar | The Calendar to change |
---|---|
period | The period to "maximise" |
Change the date of a Calendar object so that it has the minimum resolution of "period" where period is one of the constants in CALENDAR_PERIODS above.
calendar | calendar to modify |
---|---|
period | the new calendar period from CALENDAR_PERIODS |
Check whether a given duration string is valid
s | the duration string |
---|