KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joda > time > chrono > gj > TestGJDayOfWeekField


1 /*
2  * Copyright 2001-2005 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.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(), TestGJChronology.MILLIS_PER_DAY, chrono);
28     }
29
30     public int get(long millis) {
31         int dayOfWeek = (int) TestGJChronology.mod(iChronology.fixedFromMillis(millis), 7);
32         if (dayOfWeek == 0) {
33             dayOfWeek = 7;
34         }
35         return dayOfWeek;
36     }
37
38     public long set(long millis, int value) {
39         return add(millis, (long) value - get(millis));
40     }
41
42     public long add(long millis, long value) {
43         return millis + value * TestGJChronology.MILLIS_PER_DAY;
44     }
45
46     public DurationField getRangeDurationField() {
47         return iChronology.weeks();
48     }
49
50     public int getMinimumValue() {
51         return 1;
52     }
53
54     public int getMaximumValue() {
55         return 7;
56     }
57
58     public long roundFloor(long millis) {
59         return iChronology.getDateOnlyMillis(millis);
60     }
61 }
62
Popular Tags