1 /*
2  *  Copyright 2001-2014 Stephen Colebourne
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  */

16 package org.joda.time;
17
18 /**
19  * A DateTimeZone implementation for UTC.
20  * <p>
21  * This exists instead of using FixedDateTimeZone to avoid deadlocks.
22  * https://github.com/JodaOrg/joda-time/issues/171
23  */

24 final class UTCDateTimeZone extends DateTimeZone {
25
26     static final DateTimeZone INSTANCE = new UTCDateTimeZone();
27     private static final long serialVersionUID = -3513011772763289092L;
28
29     public UTCDateTimeZone() {
30         super("UTC");
31     }
32
33     @Override
34     public String getNameKey(long instant) {
35         return "UTC";
36     }
37
38     @Override
39     public int getOffset(long instant) {
40         return 0;
41     }
42
43     @Override
44     public int getStandardOffset(long instant) {
45         return 0;
46     }
47
48     @Override
49     public int getOffsetFromLocal(long instantLocal) {
50         return 0;
51     }
52
53     @Override
54     public boolean isFixed() {
55         return true;
56     }
57
58     @Override
59     public long nextTransition(long instant) {
60         return instant;
61     }
62
63     @Override
64     public long previousTransition(long instant) {
65         return instant;
66     }
67
68     @Override
69     public java.util.TimeZone toTimeZone() {
70         return new java.util.SimpleTimeZone(0, getID());
71     }
72
73     @Override
74     public boolean equals(Object obj) {
75         return (obj instanceof UTCDateTimeZone);
76     }
77
78     @Override
79     public int hashCode() {
80         return getID().hashCode();
81     }
82
83 }
84