View Javadoc

1   package com.atlassian.sal.api.timezone;
2   
3   import com.atlassian.sal.api.user.UserKey;
4   
5   import javax.annotation.Nonnull;
6   import java.util.TimeZone;
7   
8   /**
9    * @since v2.6.0
10   */
11  public interface TimeZoneManager {
12  
13      /**
14       * Returns the time zone of the logged in user.
15       * NB: This is guaranteed to return a non-null value.
16       * If no user is logged in (anonymous user) or the system doesn't support time zone configuration or no specific time zone is configured,
17       * it should still return a time zone. (e.g. the default time zone for the system).
18       *
19       * @return the user's time zone. Should never return null.
20       */
21      @Nonnull
22      TimeZone getUserTimeZone();
23  
24      /**
25       * Returns the time zone of the given user.
26       *
27       * NB: This is guaranteed to return a non-null value.
28       * If given user doesn't exists or invalid or the system doesn't support time zone configuration or no specific time zone is configured,
29       * for the given user then method still returns a time zone. (e.g. the default time zone for the system).
30       *
31       * @param user to return time zone for
32       * @return the user's time zone or default time if user not found, is invalid or has no specific time zone configured
33       * @throws NullPointerException if given user is <code>null</code>
34       * @since v2.13.0
35       */
36      @Nonnull
37      TimeZone getUserTimeZone(@Nonnull UserKey user);
38  
39      /**
40       * Returns the default time zone for the application.
41       * NB: This is guaranteed to return a non-null value.
42       *
43       * If the system doesn't support time zone configuration, it should still return a time zone (e.g. the JVM time zone).
44       *
45       * @return the default time zone of the system. Should never return null.
46       */
47      @Nonnull
48      TimeZone getDefaultTimeZone();
49  }