1 16 package org.joda.time.chrono.gj; 17 18 import org.joda.time.field.FieldUtils; 19 20 24 class TestJulianWeekyearField extends TestGJWeekyearField { 25 public TestJulianWeekyearField(TestJulianChronology chrono) { 26 super(chrono); 27 } 28 29 public long addWrapField(long millis, int value) { 30 int weekyear = get(millis); 31 int wrapped = FieldUtils.getWrappedValue 32 (weekyear, value, getMinimumValue(), getMaximumValue()); 33 return add(millis, (long) wrapped - weekyear); 34 } 35 36 public long add(long millis, long value) { 37 int weekyear = get(millis); 38 int newWeekyear = weekyear + FieldUtils.safeToInt(value); 39 if (weekyear < 0) { 40 if (newWeekyear >= 0) { 41 newWeekyear++; 42 } 43 } else { 44 if (newWeekyear <= 0) { 45 newWeekyear--; 46 } 47 } 48 return set(millis, newWeekyear); 49 } 50 51 public int getMinimumValue() { 52 return -100000000; 53 } 54 55 public int getMaximumValue() { 56 return 100000000; 57 } 58 } 59 | Popular Tags |