public class DateFormatter extends Object
FormatSettingsManager
which is passed to the constructor. Also allows for formatting into arbitrary formats.
This class is not thread-safe, primarily because DateFormat implementations are not synchronised. You should construct one instance of this class per thread or request.
TODO: Should support user locales
Constructor and Description |
---|
DateFormatter(TimeZone timeZone,
FormatSettingsManager formatSettingsManager)
Deprecated.
Since 3.2 use com.atlassian.confluence.core.DateFormatter#DateFormatter(com.atlassian.confluence.core.TimeZone,
com.atlassian.confluence.core.FormatSettingsManager, com.atlassian.confluence.languages.LocaleManager)
Create a date formatter for the specified timezone.
|
DateFormatter(TimeZone timeZone,
FormatSettingsManager formatSettingsManager,
LocaleManager localeManager) |
DateFormatter(TimeZone timeZone,
FormatSettingsManager formatSettingsManager,
LocaleManager localeManager) |
Modifier and Type | Method and Description |
---|---|
String |
format(Date date)
Formats the date and returns it as a string, using the date formatting pattern.
|
String |
format(int formatOption,
Date date)
Formats the date and returns it as a string with a formatOption defined in JDK.
|
String |
formatBlogDate(Date date)
Formats the date as a blog posting date and returns it as a string.
|
String |
formatDateFull(Date date)
Formats the date and returns it as a string, using
DateFormat.FULL as the formatting pattern. |
String |
formatDateTime(Date date)
Formats the date and returns it as a string, using the date-time formatting pattern.
|
String |
formatGivenString(String formatString,
Date date)
Formats the date and returns it as a string, using the given formatting pattern.
|
static String |
formatMillis(long millis) |
String |
formatServerDate(Date date)
Same as
format(Date) , but doesn't perform time zone conversion. |
String |
formatServerDateFull(Date date)
Same as
formatDateFull(Date) , but doesn't perform time zone conversion. |
String |
formatServerDateTime(Date date)
Same as
formatDateTime(Date) , but doesn't perform time zone conversion. |
String |
formatServerDateWithUserLocale(int formatOption,
Date date)
Same as
format(int, Date) , but doesn't perform time zone conversion. |
String |
formatTime(Date date)
Formats the date and returns it as a string, using the time formatting pattern.
|
String |
formatTimeMedium(Date date)
Formats the date and returns it as a string, using
DateFormat.MEDIUM as the time formatting pattern. |
Calendar |
getCalendar() |
String |
getCurrentDate() |
String |
getCurrentDateTime() |
String |
getDateForBlogPost(Date date) |
TimeZone |
getTimeZone() |
@Deprecated public DateFormatter(TimeZone timeZone, FormatSettingsManager formatSettingsManager)
timeZone
- the time zone in which dates will be formattedpublic DateFormatter(TimeZone timeZone, FormatSettingsManager formatSettingsManager, LocaleManager localeManager)
public DateFormatter(TimeZone timeZone, FormatSettingsManager formatSettingsManager, LocaleManager localeManager)
public String format(Date date)
The TimeZone
specified in the constructor is used to convert the date from server time to the user's
local time.
public String formatDateTime(Date date)
The TimeZone
specified in the constructor is used to convert the date from server time to the user's
local time.
public String formatTime(Date date)
The TimeZone
specified in the constructor is used to convert the date from server time to the user's
local time.
public String formatTimeMedium(Date date)
DateFormat.MEDIUM
as the time formatting pattern.
The TimeZone
specified in the constructor is used to convert the date from server time to the user's
local time.
public String formatDateFull(Date date)
DateFormat.FULL
as the formatting pattern.
The TimeZone
specified in the constructor is used to convert the date from server time to the user's
local time.
public String format(int formatOption, Date date)
The TimeZone
specified in the constructor is used to convert the date from server time to the user's
local time.
public String formatServerDate(Date date)
format(Date)
, but doesn't perform time zone conversion.
This is typically used for formatting the posting dates of news items, which must be represented the same for all users.
public String formatServerDateWithUserLocale(int formatOption, Date date)
format(int, Date)
, but doesn't perform time zone conversion.
This is typically used for formatting the posting dates of news items, which must be represented the same for all users.
public String formatServerDateTime(Date date)
formatDateTime(Date)
, but doesn't perform time zone conversion.
This is typically used for formatting the posting dates of news items, which must be represented the same for all users.
public String formatBlogDate(Date date)
This method does not apply the TimeZone
specified in the constructor, but instead uses server's
default time zone. A blog post date is part of its identifier, therefore it must be consistent for all users.
public String formatServerDateFull(Date date)
formatDateFull(Date)
, but doesn't perform time zone conversion.
This is typically used for formatting the posting dates of news items, which must be represented the same for all users.
public String formatGivenString(String formatString, Date date)
The TimeZone
specified in the constructor is used to convert the date from server time to the user's
local time.
public String getCurrentDateTime()
formatDateTime(Date)
public String getCurrentDate()
format(Date)
public String getDateForBlogPost(Date date)
public Calendar getCalendar()
TimeZone
specified in the constructor.public TimeZone getTimeZone()
TimeZone
provided when this formatter was created.public static String formatMillis(long millis)
Copyright © 2003–2016 Atlassian. All rights reserved.