1 16 package org.joda.time.chrono.gj; 17 18 import org.joda.time.DateTimeFieldType; 19 import org.joda.time.DurationField; 20 21 25 class TestGJWeekOfWeekyearField extends TestGJDateTimeField { 26 public TestGJWeekOfWeekyearField(TestGJChronology chrono) { 27 super(DateTimeFieldType.weekOfWeekyear(), 28 (long)(TestGJChronology.MILLIS_PER_DAY * 7), chrono); 29 } 30 31 public int get(long millis) { 32 return iChronology.isoFromMillis(millis)[1]; 33 } 34 35 public long set(long millis, int value) { 36 int[] wwd = iChronology.isoFromMillis(millis); 37 return iChronology.getTimeOnlyMillis(millis) 38 + iChronology.millisFromISO(wwd[0], value, wwd[2]); 39 } 40 41 public long add(long millis, long value) { 42 return iChronology.dayOfYear().add(millis, value * 7); 43 } 44 45 public DurationField getRangeDurationField() { 46 return iChronology.weeks(); 47 } 48 49 public int getMinimumValue() { 50 return 1; 51 } 52 53 public int getMaximumValue() { 54 return 53; 55 } 56 57 public int getMaximumValue(long millis) { 58 millis = iChronology.weekyear().roundFloor(millis); 60 millis = iChronology.weekyear().add(millis, 1); 61 millis = iChronology.dayOfYear().add(millis, -1); 62 return get(millis); 63 } 64 65 public long roundFloor(long millis) { 66 int[] wwd = iChronology.isoFromMillis(millis); 67 return iChronology.millisFromISO(wwd[0], wwd[1], 1); 68 } 69 } 70 | Popular Tags |