com.atlassian.confluence.core.datetime
Class FriendlyDateFormatter
java.lang.Object
com.atlassian.confluence.core.datetime.FriendlyDateFormatter
public class FriendlyDateFormatter
- extends java.lang.Object
Formats a date in a relative, friendly way. For example, "2 minutes ago". A DateFormatter
is used to
format some dates according to the server's formats and the user's time zone. As such, you will need a new
instance of this class for each user and "current time", typically one per request.
It is recommended that you pass a "now" time to the constructor to ensure that times are formatted
against a known standard point in time. The alternate constructor uses the time that this object is created,
which is probably not very useful.
This class is not thread-safe, primarily because it uses a DateFormatter class which is not thread-safe.
Method Summary |
Message |
getFormatMessage(java.util.Date date)
Returns the i18n message to format the given date relative to the "now" time passed to the constructor. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FriendlyDateFormatter
public FriendlyDateFormatter(DateFormatter dateFormatter)
FriendlyDateFormatter
public FriendlyDateFormatter(java.util.Date now,
DateFormatter dateFormatter)
getFormatMessage
public Message getFormatMessage(java.util.Date date)
- Returns the i18n message to format the given date relative to the "now" time passed to the constructor.
- Parameters:
date
- the date to format
- Returns:
- the i18n message which can be used to format the date relative to the "now" time
Copyright © 2003-2014 Atlassian. All Rights Reserved.