|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@ThreadSafe @InjectableComponent public interface DateTimeFormatter
Interface for JIRA date time formatters. All formatters are time zone-aware (the actual time zone that they use when
formatting dates will depend on how they were created). Formatters can be injected directly into other classes or
alternatively created using DateTimeFormatterFactory
. See
com.atlassian.jira.datetime for examples of how to use DateTimeFormatter. Example:
DateTimeFormatterFactory
Method Summary | |
---|---|
DateTimeFormatter |
forLoggedInUser()
Returns a new formatter that will use the time zone and locale of the user that is logged in when format and/or parse are called, if any (as specified by JiraAuthenticationContext ). |
String |
format(Date date)
Formats a Date as a human-readable string, using the date/time style returned by getStyle(). |
DateTimeFormatter |
forUser(com.atlassian.crowd.embedded.api.User user)
Returns a new formatter that will use the given user's time zone and locale. |
String |
getFormatHint()
Returns a hint for this formatter. |
Locale |
getLocale()
|
DateTimeStyle |
getStyle()
Returns this formatter's style. |
TimeZone |
getZone()
Returns this formatter's time zone. |
Date |
parse(String text)
Parses a date from the given text, returning a new Date. |
DateTimeFormatter |
withDefaultLocale()
Returns a new formatter that will use the JIRA default locale to format and parse dates. |
DateTimeFormatter |
withDefaultZone()
Returns a new formatter that will use the JIRA default time zone to format and parse dates. |
DateTimeFormatter |
withLocale(Locale locale)
Specifies the Locale to use when formatting dates. |
DateTimeFormatter |
withStyle(DateTimeStyle style)
Specifies the style to use when formatting dates. |
DateTimeFormatter |
withSystemZone()
Returns a new formatter that will use the system time zone to format and parse dates. |
DateTimeFormatter |
withZone(TimeZone timeZone)
Returns a new formatter that will use the specified zone instead of the JIRA default time zone. |
Method Detail |
---|
String format(Date date)
date
- a Date instance
Date parse(String text) throws IllegalArgumentException, UnsupportedOperationException
text
- a String containing a date
IllegalArgumentException
- if the input text can not be parsed
UnsupportedOperationException
- if this strategy does not support parsingDateTimeFormatter forLoggedInUser()
JiraAuthenticationContext
). If there is no logged in user, or if the logged in user has not configured a time
zone and/or locale, the JIRA default time zone and/or locale is used.
It is intended that clients will reuse the formatter obtained from this method across requests: it will always
use the time zone and locale of the currently logged in user.
JiraAuthenticationContext.getLoggedInUser()
DateTimeFormatter forUser(@Nullable com.atlassian.crowd.embedded.api.User user)
user
- the User whose time zone and locale the new formatter will use
DateTimeFormatter withDefaultZone()
DateTimeFormatter withSystemZone()
TimeZone.getDefault()
DateTimeFormatter withZone(@Nullable TimeZone timeZone)
timeZone
- a TimeZone
DateTimeFormatter withDefaultLocale()
DateTimeFormatter withLocale(@Nullable Locale locale)
locale
- a Locale
DateTimeFormatter withStyle(@Nullable DateTimeStyle style)
style
- a DateTimeStyle
TimeZone getZone()
Locale getLocale()
DateTimeStyle getStyle()
String getFormatHint()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |