01: /*
02: * Copyright 2001-2005 Stephen Colebourne
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.chrono.gj;
17:
18: import org.joda.time.DateTimeFieldType;
19: import org.joda.time.DurationField;
20:
21: /**
22: *
23: * @author Brian S O'Neill
24: */
25: class TestGJDayOfWeekField extends TestGJDateTimeField {
26: public TestGJDayOfWeekField(TestGJChronology chrono) {
27: super (DateTimeFieldType.dayOfWeek(),
28: TestGJChronology.MILLIS_PER_DAY, chrono);
29: }
30:
31: public int get(long millis) {
32: int dayOfWeek = (int) TestGJChronology.mod(iChronology
33: .fixedFromMillis(millis), 7);
34: if (dayOfWeek == 0) {
35: dayOfWeek = 7;
36: }
37: return dayOfWeek;
38: }
39:
40: public long set(long millis, int value) {
41: return add(millis, (long) value - get(millis));
42: }
43:
44: public long add(long millis, long value) {
45: return millis + value * TestGJChronology.MILLIS_PER_DAY;
46: }
47:
48: public DurationField getRangeDurationField() {
49: return iChronology.weeks();
50: }
51:
52: public int getMinimumValue() {
53: return 1;
54: }
55:
56: public int getMaximumValue() {
57: return 7;
58: }
59:
60: public long roundFloor(long millis) {
61: return iChronology.getDateOnlyMillis(millis);
62: }
63: }
|