|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.core.util.DateUtils
public class DateUtils
| Nested Class Summary | |
|---|---|
static class |
DateUtils.DateRange
|
static class |
DateUtils.Duration
|
| Field Summary | |
|---|---|
static String |
AM
|
static long |
DAY_MILLIS
|
static long |
HOUR_MILLIS
|
static DateFormat |
ISO8601DateFormat
Date Format to be used for internal logging operations |
static long |
MINUTE_MILLIS
|
static long |
MONTH_MILLIS
|
static String |
PM
|
static long |
SECOND_MILLIS
|
static long |
YEAR_MILLIS
|
| Constructor Summary | |
|---|---|
DateUtils(ResourceBundle resourceBundle)
|
|
| Method Summary | |
|---|---|
static String |
dateDifference(long dateA,
long dateB,
long resolution,
ResourceBundle resourceBundle)
Resolution is the degree of difference. |
String |
dateDifferenceBean(long dateA,
long dateB,
long resolution,
ResourceBundle resourceBundle)
|
static boolean |
equalTimestamps(Timestamp t1,
Timestamp t2)
compares if these two timestamps are within 10 milliseconds of each other (precision error) |
static String |
formatDateISO8601(Date ts)
|
String |
formatDurationPretty(long l)
This is used by the Velocity templates as a bean |
String |
formatDurationPretty(String seconds)
This is used by the Velocity templates as a bean |
String |
formatDurationString(long l)
Deprecated. You should be calling formatDurationPretty |
static int |
get24HourTime(String meridianIndicator,
int hours)
|
static Calendar |
getCalendarDay(int year,
int month,
int day)
|
static Date |
getDateDay(int year,
int month,
int day)
|
static long |
getDuration(String durationStr)
Given a duration string, get the number of seconds it represents (all case insensitive): w = weeks d = days h = hours m = minutes If no category is specified, assume minutes. Each field must be separated by a space, and they can come in any order. |
static long |
getDuration(String durationStr,
DateUtils.Duration defaultUnit)
Given a duration string, get the number of seconds it represents (all case insensitive): w = weeks d = days h = hours m = minutes ie 2h = 7200, 60m = 3600, 3d = 259200, 30m |
static long |
getDuration(String durationStr,
int hoursPerDay,
int daysPerWeek)
This function retrieves a duration in seconds that depends on number of hours in a day and days in a week. |
static long |
getDuration(String durationStr,
int hoursPerDay,
int daysPerWeek,
DateUtils.Duration defaultUnit)
This function retrieves a duration in seconds that depends on number of hours in a day and days in a week |
static String |
getDurationPretty(long numSecs,
int hoursPerDay,
int daysPerWeek,
ResourceBundle resourceBundle)
Converts a number of seconds into a pretty formatted data string. |
static String |
getDurationPretty(long numSecs,
ResourceBundle resourceBundle)
Converts a number of seconds into a pretty formatted data string. |
static String |
getDurationPrettySeconds(long numSecs,
long secondsPerDay,
long secondsPerWeek,
ResourceBundle resourceBundle)
Get a pretty formatted duration for the given number of seconds. |
static String |
getDurationPrettySecondsResolution(long numSecs,
int hoursPerDay,
int daysPerWeek,
ResourceBundle resourceBundle)
Converts a number of seconds into a pretty formatted data string. |
static String |
getDurationPrettySecondsResolution(long numSecs,
ResourceBundle resourceBundle)
Converts a number of seconds into a pretty formatted data string. |
static long |
getDurationSeconds(String durationStr,
long secondsPerDay,
long secondsPerWeek,
DateUtils.Duration defaultUnit)
Convert a duration string in the number of seconds it represents. |
static String |
getDurationString(long seconds)
Get String representation of a duration |
static String |
getDurationString(long l,
int hoursPerDay,
int daysPerWeek)
Get a duration string representing the given number of seconds. |
static String |
getDurationStringSeconds(long l,
long secondsPerDay,
long secondsPerWeek)
Get a duration string representing the given number of seconds. |
static String |
getDurationStringWithNegative(long seconds)
Get String representation of a (possibly negative) duration. |
static long |
getDurationWithNegative(String durationStr)
Get a duration string with the possibility of a negative. |
static Date |
getSqlDateDay(int year,
int month,
int day)
|
static DateUtils.DateRange |
toDateRange(Calendar date,
int period)
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 <= {range} < endDate] |
static Calendar |
toEndOfPeriod(Calendar calendar,
int period)
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. |
static Date |
tomorrow()
|
static Calendar |
toStartOfPeriod(Calendar calendar,
int period)
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. |
static boolean |
validDuration(String s)
Check whether a given duration string is valid |
static Date |
yesterday()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long SECOND_MILLIS
public static final long MINUTE_MILLIS
public static final long HOUR_MILLIS
public static final long DAY_MILLIS
public static final long MONTH_MILLIS
public static final long YEAR_MILLIS
public static final String AM
public static final String PM
public static final DateFormat ISO8601DateFormat
| Constructor Detail |
|---|
public DateUtils(ResourceBundle resourceBundle)
| Method Detail |
|---|
public static boolean equalTimestamps(Timestamp t1,
Timestamp t2)
t1 - first timestamp to comparet2 - second timestamp to compare
public String dateDifferenceBean(long dateA,
long dateB,
long resolution,
ResourceBundle resourceBundle)
public static String dateDifference(long dateA,
long dateB,
long resolution,
ResourceBundle resourceBundle)
dateA - first date to comparedateB - second date to compareresolution - the degree of differenceresourceBundle - contains localizations for core.dateutils strings
public static String formatDateISO8601(Date ts)
public static boolean validDuration(String s)
s - the duration string
public static long getDuration(String durationStr)
throws InvalidDurationException
durationStr - the duration string
InvalidDurationException - if the duration is invalid
public static long getDuration(String durationStr,
DateUtils.Duration defaultUnit)
throws InvalidDurationException
durationStr - the duration stringdefaultUnit - the unit used when another is not specified in the durationStr
InvalidDurationException - if the duration is invalid
public static long getDuration(String durationStr,
int hoursPerDay,
int daysPerWeek)
throws InvalidDurationException
durationStr - to convert to a durationhoursPerDay - Number of hourse i daydaysPerWeek - Days Per Week
InvalidDurationException - if its badly formatted duration
public static long getDuration(String durationStr,
int hoursPerDay,
int daysPerWeek,
DateUtils.Duration defaultUnit)
throws InvalidDurationException
durationStr - to convert to a durationhoursPerDay - Number of hourse i daydaysPerWeek - Days Per WeekdefaultUnit - the unit used when one is not specified on a measure in the durationStr
InvalidDurationException - if its badly formatted duration
public static long getDurationWithNegative(String durationStr)
throws InvalidDurationException
durationStr - the duration string
InvalidDurationException - if its a badly formatted duration
public static long getDurationSeconds(String durationStr,
long secondsPerDay,
long secondsPerWeek,
DateUtils.Duration defaultUnit)
throws InvalidDurationException
durationStr - the duration stringsecondsPerDay - 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 parsedpublic static String getDurationString(long seconds)
seconds - Number of seconds
getDurationStringWithNegative(long)public static String getDurationStringWithNegative(long seconds)
seconds - Number of seconds
getDurationString(long)
public static String getDurationString(long l,
int hoursPerDay,
int daysPerWeek)
l - the number of secondshoursPerDay - hours in a working daydaysPerWeek - days in a working week
public static String getDurationStringSeconds(long l,
long secondsPerDay,
long secondsPerWeek)
l - the number of secondssecondsPerDay - the number of seconds in a working daysecondsPerWeek - the number of seconds in a working week
public static String getDurationPretty(long numSecs,
ResourceBundle resourceBundle)
76 becomes '1 minute', while 42 becomes '42 seconds'
numSecs - the number of seconds in the durationresourceBundle - a resouce bundle for i18n
public static String getDurationPretty(long numSecs,
int hoursPerDay,
int daysPerWeek,
ResourceBundle resourceBundle)
76 becomes '1 minute', while 42 becomes '42 seconds'
numSecs - the number of seconds in the durationhoursPerDay - the hours in a daydaysPerWeek - the number of days in a weekresourceBundle - a resouce bundle for i18n
public static String getDurationPrettySecondsResolution(long numSecs,
ResourceBundle resourceBundle)
76 becomes '1 minute, 16 seconds', while 42 becomes '42 seconds'
numSecs - the number of seconds in the durationresourceBundle - a resouce bundle for i18n
public static String getDurationPrettySecondsResolution(long numSecs,
int hoursPerDay,
int daysPerWeek,
ResourceBundle resourceBundle)
76 becomes '1 minute, 16 seconds', while 42 becomes '42 seconds'
numSecs - the number of seconds in the durationhoursPerDay - the hours in a daydaysPerWeek - the number of days in a weekresourceBundle - a resouce bundle for i18n
public static String getDurationPrettySeconds(long numSecs,
long secondsPerDay,
long secondsPerWeek,
ResourceBundle resourceBundle)
numSecs - the number of seconds in the durationsecondsPerDay - 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")
public String formatDurationPretty(long l)
l - a duration in seconds
public String formatDurationPretty(String seconds)
seconds - duration as a string
public String formatDurationString(long l)
l - a duration in seconds
formatDurationPretty(long)
public static Calendar toEndOfPeriod(Calendar calendar,
int period)
calendar - The Calendar to changeperiod - The period to "maximise"
public static Calendar toStartOfPeriod(Calendar calendar,
int period)
calendar - calendar to modifyperiod - the new calendar period from CALENDAR_PERIODS
public static DateUtils.DateRange toDateRange(Calendar date,
int period)
date - a calendar object of a date falling in that rangeperiod - something in CALENDAR_PERIODS
public static Calendar getCalendarDay(int year,
int month,
int day)
public static Date getDateDay(int year,
int month,
int day)
public static Date getSqlDateDay(int year,
int month,
int day)
public static int get24HourTime(String meridianIndicator,
int hours)
public static Date tomorrow()
public static Date yesterday()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||