001 /*
002 * Copyright 2001-2005 Stephen Colebourne
003 *
004 * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.joda.time.tz;
017
018 import java.util.Collections;
019 import java.util.Set;
020 import org.joda.time.DateTimeZone;
021
022 /**
023 * Simple time zone provider that supports only UTC.
024 * <p>
025 * UTCProvider is thread-safe and immutable.
026 *
027 * @author Brian S O'Neill
028 * @since 1.0
029 */
030 public final class UTCProvider implements Provider {
031
032 /**
033 * Constructor.
034 */
035 public UTCProvider() {
036 super();
037 }
038
039 /**
040 * Returns {@link DateTimeZone#UTC UTC} for <code>"UTC"</code>, null
041 * otherwise.
042 */
043 public DateTimeZone getZone(String id) {
044 if ("UTC".equalsIgnoreCase(id)) {
045 return DateTimeZone.UTC;
046 }
047 return null;
048 }
049
050 /**
051 * Returns a singleton collection containing only <code>"UTC"</code>.
052 */
053 public Set getAvailableIDs() {
054 return Collections.singleton("UTC");
055 }
056
057 }