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