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