public class

OutlookDate

extends Object
java.lang.Object
   ↳ com.atlassian.jira.web.util.OutlookDate

Class Overview

Formats and parses dates in a variety of formats, including relative dates such as "Today" and "Last Wednesday".

Warning

As of JIRA 4.4, some of the methods in this class have been retrofitted to be time zone-aware. This means that if you call one of these methods, this class will attempt to determine the time zone of the user that is currently logged in, and will display times in that user's time zone if possible. If the user's time zone can not be determined, or if there is no logged in user, the methods will use the JIRA default user time zone. This is different to the previous behaviour, which was to use the JVM default timezone as returned by getDefault() when displaying dates. Please review each method's JavaDoc to determine whether you are affected by this change in behaviour.

Summary

Nested Classes
enum OutlookDate.SmartFormatterModes This enum is deprecated. Use DateTimeFormatter instead. Since v5.0.  
Constants
long DAY
long HOUR
long MINUTE
int OTHER
long SECOND
int THIS_WEEK
int TODAY
int YESTERDAY
Public Constructors
OutlookDate(Locale locale, ApplicationProperties applicationProperties, I18nHelper.BeanFactory i18nHelperFactory, DateTimeFormatterFactory dateTimeFormatterFactory)
OutlookDate(Locale locale)
OutlookDate(Locale locale, ApplicationProperties applicationProperties)
Public Methods
@Deprecated int daysAgo(Date date)
This method is deprecated. Use daysBetween(org.joda.time.ReadablePartial, org.joda.time.ReadablePartial) instead. Since v4.4.
@Deprecated int daysAgo(Date theDate, Date theReferenceDate)
This method is deprecated. Use daysBetween(org.joda.time.ReadablePartial, org.joda.time.ReadablePartial) instead. Since v4.4.
@Deprecated String format(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated String format()
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated String formatDMY(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated String formatDMYHMS(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v5.0.
@Deprecated String formatDatePicker(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated String formatDateTimePicker(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated String formatDay(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
String formatIso8601(Date date)
Formats the given date into ISO8601 format.
String formatIso8601Date(Date date)
Formats the given date into ISO8601 format.
@Deprecated String formatRss(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v5.0.
@Deprecated String formatRssRfc822(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated String formatSmart(Date date, OutlookDate.SmartFormatterModes mode)
This method is deprecated. Use format(java.util.Date) instead. Since v5.0.
@Deprecated String formatTime(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v5.0.
@Deprecated DateFormat getCompleteDateFormat()
This method is deprecated. Use getFormatHint() instead. Since v4.4.
@Deprecated String getCompleteDateTimeFormat()
This method is deprecated. Use getFormatHint() instead. Since v4.4.
@Deprecated String getDatePickerFormat()
This method is deprecated. Use getFormatHint() instead. Since v4.4.
@Deprecated String getDatePickerFormatSample(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated String getDateTimePickerFormat()
This method is deprecated. Use getFormatHint() instead. Since v4.4.
@Deprecated String getDateTimePickerFormatSample(Date date)
This method is deprecated. Use format(java.util.Date) instead. Since v4.4.
@Deprecated Date getNow()
This method is deprecated. Use Date() instead. Since v4.4.
@Deprecated boolean isDatePickerDate(String value)
This method is deprecated. Use parse(String) instead. Since v5.0.
@Deprecated Date parseCompleteDateTime(String value)
This method is deprecated. Use parse(String) instead. Since v4.4.
@Deprecated Date parseDatePicker(String value)
This method is deprecated. Use parse(String) instead. Since v4.4.
@Deprecated Date parseDateTimePicker(String value)
This method is deprecated. Use parse(String) instead. Since v4.4.
@Deprecated static Date parseRss(String rssDate)
This method is deprecated. Use parse(String) instead. Since v5.0.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final long DAY

Constant Value: 86400000 (0x0000000005265c00)

public static final long HOUR

Constant Value: 3600000 (0x000000000036ee80)

public static final long MINUTE

Constant Value: 60000 (0x000000000000ea60)

public static final int OTHER

Constant Value: 3 (0x00000003)

public static final long SECOND

Constant Value: 1000 (0x00000000000003e8)

public static final int THIS_WEEK

Constant Value: 2 (0x00000002)

public static final int TODAY

Constant Value: 0 (0x00000000)

public static final int YESTERDAY

Constant Value: 1 (0x00000001)

Public Constructors

public OutlookDate (Locale locale, ApplicationProperties applicationProperties, I18nHelper.BeanFactory i18nHelperFactory, DateTimeFormatterFactory dateTimeFormatterFactory)

public OutlookDate (Locale locale)

public OutlookDate (Locale locale, ApplicationProperties applicationProperties)

Public Methods

@Deprecated public int daysAgo (Date date)

This method is deprecated.
Use daysBetween(org.joda.time.ReadablePartial, org.joda.time.ReadablePartial) instead. Since v4.4.

@Deprecated public int daysAgo (Date theDate, Date theReferenceDate)

This method is deprecated.
Use daysBetween(org.joda.time.ReadablePartial, org.joda.time.ReadablePartial) instead. Since v4.4.

The method determines whether the date (theDate) lies between the reference date and the previous midnight (TODAY), between the reference date and the midnight before previous (YESTERDAY), or between the reference date and 7 midnights ago (THIS_WEEK). If the passed in date does not fall in any of the mentioned ranges, the method returns OTHER.

Parameters
theDate the date we are asking about
theReferenceDate the reference date (usually today's date)

@Deprecated public String format (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

Returns the given date formatted as a String in the current user's time zone if possible, in the format specified by RELATIVE.

Parameters
date the date to format
Returns
  • the date printed (i18n)

@Deprecated public String format ()

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

Returns the current date formatted as a String in the current user's time zone if possible, in the format specified by RELATIVE.

@Deprecated public String formatDMY (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

Returns the given date formatted as a String in the current user's time zone if possible, in the format specified by DATE.

Parameters
date a Date
Returns
  • a String containing the formatted date

@Deprecated public String formatDMYHMS (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v5.0.

Returns the given date formatted as a String in the current user's time zone if possible, in the format specified by COMPLETE.

Parameters
date a Date
Returns
  • a String containing the formatted date

@Deprecated public String formatDatePicker (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

Returns the given date formatted as a String in the current user's time zone if possible, in the format specified by DATE_PICKER.

@Deprecated public String formatDateTimePicker (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

Returns the given date formatted as a String in the current user's time zone if possible, in the format specified by DATE_TIME_PICKER.

@Deprecated public String formatDay (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

public String formatIso8601 (Date date)

Formats the given date into ISO8601 format. This format contains date and time information and it is used by data marked with hCalendar microformat. If you need to use date information only use formatIso8601Date(java.util.Date) method instead.

Parameters
date date to format
Returns
  • formatted date string

public String formatIso8601Date (Date date)

Formats the given date into ISO8601 format. This format contains date information only and it is used by data marked with hCalendar microformat. If you need to use date and time information use formatIso8601(java.util.Date) method instead.

Parameters
date date to format
Returns
  • formatted date string

@Deprecated public String formatRss (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v5.0.

Format a date for RSS feeds. Uses MailDateFormat to format the given date. Returns an empty string if null is passed in.

Parameters
date date to format
Returns
  • formatted date or empty string

@Deprecated public String formatRssRfc822 (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

Formats a date using the correct RFC822 format as indicated in the RSS v2 specification and not using the MailDateFormat which is technically incorrect. MailDateFormat will however parse this format.

See http://cyber.law.harvard.edu/rss/rss.html

See http://asg.web.cmu.edu/rfc/rfc822.html#sec-5.1

Correct : Wed, 22 Aug 2007 10:00:10 +1000

Incorrect : Wed, 22 Aug 2007 10:00:10 +1000 (GMT+10:00)

Parameters
date the date to format into a string
Returns
  • a date string in RFC822 format

@Deprecated public String formatSmart (Date date, OutlookDate.SmartFormatterModes mode)

This method is deprecated.
Use format(java.util.Date) instead. Since v5.0.

Format the date "smartly", by using the day of the week if the date falls within a week in either direction of the current date. If the date is in the past, we will use terminology such as "last Wednesday" to differentiate it from "Wednesday" (which is in the future).

Parameters
date the date to format
mode whether or not to include the time in the printed date
Returns
  • the date printed (i18n)

@Deprecated public String formatTime (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v5.0.

Returns the given date formatted as a String in the current user's time zone if possible, in the format specified by TIME.

Parameters
date a Date
Returns
  • a String containing the formatted date

@Deprecated public DateFormat getCompleteDateFormat ()

This method is deprecated.
Use getFormatHint() instead. Since v4.4.

This helper is here to assist with formatting emails etc, and should only be used by JIRAVelocityManager.

Returns

@Deprecated public String getCompleteDateTimeFormat ()

This method is deprecated.
Use getFormatHint() instead. Since v4.4.

@Deprecated public String getDatePickerFormat ()

This method is deprecated.
Use getFormatHint() instead. Since v4.4.

@Deprecated public String getDatePickerFormatSample (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

@Deprecated public String getDateTimePickerFormat ()

This method is deprecated.
Use getFormatHint() instead. Since v4.4.

@Deprecated public String getDateTimePickerFormatSample (Date date)

This method is deprecated.
Use format(java.util.Date) instead. Since v4.4.

@Deprecated public Date getNow ()

This method is deprecated.
Use Date() instead. Since v4.4.

Returns new date

Returns
  • new date

@Deprecated public boolean isDatePickerDate (String value)

This method is deprecated.
Use parse(String) instead. Since v5.0.

@return

@Deprecated public Date parseCompleteDateTime (String value)

This method is deprecated.
Use parse(String) instead. Since v4.4.

Parses the given text in COMPLETE format, using the current user's time zone and locale if possible. If there is no currently logged in user, or if the currently logged in user has not configured a time zone and/or locale the JIRA default time zone and/or locale is used.

@Deprecated public Date parseDatePicker (String value)

This method is deprecated.
Use parse(String) instead. Since v4.4.

Parses the given text in DATE_PICKER or DATE_TIME_PICKER format, using the current user's time zone and locale if possible. If there is no currently logged in user, or if the currently logged in user has not configured a time zone and/or locale the JIRA default time zone and/or locale is used.

@Deprecated public Date parseDateTimePicker (String value)

This method is deprecated.
Use parse(String) instead. Since v4.4.

Parses the given text in DATE_TIME_PICKER format, using the current user's time zone and locale if possible. If there is no currently logged in user, or if the currently logged in user has not configured a time zone and/or locale the JIRA default time zone and/or locale is used.

@Deprecated public static Date parseRss (String rssDate)

This method is deprecated.
Use parse(String) instead. Since v5.0.

Parse a date from RSS feeds. Uses MailDateFormat to parse the date.

Parameters
rssDate RSS date
Returns
  • new Date created from the given string
Throws
ParseException if string parsing fails