Class UserTimeZoneService

java.lang.Object
io.meeds.social.timezone.service.UserTimeZoneService

@Service public class UserTimeZoneService extends Object
Holds the timezone of each user, the one his browser lives in, under the profile attribute Profile.USER_TIME_ZONE. The browser of the user keeps it up to date on every page load, so that everything sent to him on a schedule, starting with the digest mail notifications, goes out at the right local hour. This synchronization used to live in the agenda addon and is now owned by the platform, so that it works whatever the installed addons; agenda delegates its own copy here.
  • Field Details

    • USER_TIME_ZONE_SAVED_EVENT

      public static final String USER_TIME_ZONE_SAVED_EVENT
      Event broadcast when the timezone of a user is saved, with the username as source and the timezone as data. A profile listener can't be used for that: it never fires when this attribute changes.
      See Also:
  • Constructor Details

    • UserTimeZoneService

      public UserTimeZoneService(org.exoplatform.services.organization.OrganizationService organizationService, org.exoplatform.services.listener.ListenerService listenerService)
  • Method Details

    • getUserTimeZone

      public String getUserTimeZone(String username)
      Parameters:
      username - the user to read the timezone of
      Returns:
      the timezone of the user, null when it is unknown: a user who never loaded a page has no timezone yet. The caller falls back to the server timezone.
    • saveUserTimeZone

      public void saveUserTimeZone(String username, String zoneId)
      Saves the timezone the browser of the user lives in, then broadcasts USER_TIME_ZONE_SAVED_EVENT so that whatever keeps a copy of the timezone, like the digest work list, can refresh it.
      Parameters:
      username - the user to save the timezone of
      zoneId - the timezone identifier, for example Europe/Paris
      Throws:
      IllegalArgumentException - when the timezone is not a known one
      IllegalStateException - when the profile of the user can't be saved