001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.timezone.service; 017 018 import java.util.List; 019 020 import org.joda.time.DateTimeZone; 021 import org.kuali.hr.core.KPMEConstants; 022 import org.kuali.hr.time.timeblock.TimeBlock; 023 import org.springframework.cache.annotation.Cacheable; 024 025 public interface TimezoneService { 026 027 /** 028 * Returns the DateTimeZone object for the current user OR the system 029 * default timezone if there is no current user / a time zone is missing. 030 * 031 * @return 032 */ 033 public DateTimeZone getUserTimezoneWithFallback(); 034 035 /** 036 * Fetch user time zone of the current on-context user. 037 * @return 038 */ 039 public String getUserTimezone(); 040 041 /** 042 * (this call may be cached) 043 * Fetch the users timezone, Data on: 044 * 045 * Principal Calendar > Job/Location > System Default 046 * 047 * @param principalId The principal you are looking for. 048 * 049 * @return String timezone, see: http://joda-time.sourceforge.net/timezones.html 050 */ 051 @Cacheable(value= KPMEConstants.KPME_GLOBAL_CACHE_NAME, key="'{UserTimezone}' + 'principalId=' + #p0") 052 public String getUserTimezone(String principalId); 053 054 /** 055 * Translate TimeBlocks to a given timezone 056 * @param timeBlocks 057 * @param timezone 058 * @return 059 */ 060 public List<TimeBlock> translateForTimezone(List<TimeBlock> timeBlocks, String timezone); 061 062 public void translateForTimezone(List<TimeBlock> timeBlocks); 063 064 /** 065 * Determine if Timezone is same as server timezone 066 * @return 067 */ 068 public boolean isSameTimezone(); 069 070 public long getTimezoneOffsetFromServerTime(DateTimeZone dtz); 071 }