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 TestGJWeekyearField extends TestGJDateTimeField { 26 public TestGJWeekyearField(TestGJChronology chrono) { 27 super(DateTimeFieldType.weekyear(), chrono.millisPerYear(), chrono); 28 } 29 30 public int get(long millis) { 31 return iChronology.isoFromMillis(millis)[0]; 32 } 33 34 public long set(long millis, int value) { 35 int[] wwd = iChronology.isoFromMillis(millis); 36 millis = iChronology.getTimeOnlyMillis(millis) 37 + iChronology.millisFromISO(value, wwd[1], wwd[2]); 38 if (wwd[1] == 53) { 39 int[] wwd2 = iChronology.isoFromMillis(millis); 40 if (wwd2[0] != value) { 41 millis = iChronology.dayOfYear().add(millis, -7); 43 } 44 } 45 return millis; 46 } 47 48 public long add(long millis, long value) { 49 return set(millis, (int)(get(millis) + value)); 50 } 51 52 public boolean isLeap(long millis) { 53 return iChronology.weekOfWeekyear().getMaximumValue(millis) > 52; 54 } 55 56 public int getLeapAmount(long millis) { 57 return iChronology.weekOfWeekyear().getMaximumValue(millis) - 52; 58 } 59 60 public DurationField getLeapDurationField() { 61 return iChronology.weeks(); 62 } 63 64 public DurationField getRangeDurationField() { 65 return null; 66 } 67 68 public int getMinimumValue() { 69 return -100000000; 70 } 71 72 public int getMaximumValue() { 73 return 100000000; 74 } 75 76 public long roundFloor(long millis) { 77 return iChronology.millisFromISO(get(millis), 1, 1); 78 } 79 } 80 | Popular Tags |