View Javadoc

1   /*
2    *  Copyright 2001-2007 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  public class MockZone extends DateTimeZone {
19  
20      long transition;
21      int winterOffset;
22      int sizeMillis;
23  
24      public MockZone(long transition, int winterOffset, int sizeSecs) {
25          super("MockZone");
26          this.transition = transition;
27          this.winterOffset = winterOffset;
28          this.sizeMillis = sizeSecs * 1000;
29      }
30  
31      public int getOffset(long instant) {
32          return (instant < transition ? winterOffset : winterOffset + sizeMillis);
33      }
34  
35      public int getStandardOffset(long instant) {
36          return winterOffset;
37      }
38  
39      public long nextTransition(long instant) {
40          return (instant < transition ? transition : transition + 180L * DateTimeConstants.MILLIS_PER_DAY);
41      }
42  
43      public long previousTransition(long instant) {
44          return (instant > transition ? transition : transition - 180L * DateTimeConstants.MILLIS_PER_DAY);
45      }
46  
47      public boolean isFixed() {
48          return false;
49      }
50  
51      public String getNameKey(long instant) {
52          return null;
53      }
54  
55      public boolean equals(Object object) {
56          return false;
57      }
58  }