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 TestGJDayOfMonthField extends TestGJDateTimeField { 26 public TestGJDayOfMonthField(TestGJChronology chrono) { 27 super(DateTimeFieldType.dayOfMonth(), TestGJChronology.MILLIS_PER_DAY, chrono); 28 } 29 30 public int get(long millis) { 31 return iChronology.gjFromMillis(millis)[2]; 32 } 33 34 public long set(long millis, int value) { 35 int[] ymd = iChronology.gjFromMillis(millis); 36 return iChronology.getTimeOnlyMillis(millis) 37 + iChronology.millisFromGJ(ymd[0], ymd[1], value); 38 } 39 40 public long add(long millis, long value) { 41 return millis + value * TestGJChronology.MILLIS_PER_DAY; 42 } 43 44 public DurationField getRangeDurationField() { 45 return iChronology.months(); 46 } 47 48 public int getMinimumValue() { 49 return 1; 50 } 51 52 public int getMaximumValue() { 53 return 31; 54 } 55 56 public int getMaximumValue(long millis) { 57 int[] lengths = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 58 if (iChronology.year().isLeap(millis)) { 59 lengths[2] = 29; 60 } 61 return lengths[iChronology.monthOfYear().get(millis)]; 62 } 63 64 public long roundFloor(long millis) { 65 return iChronology.getDateOnlyMillis(millis); 66 } 67 } 68 | Popular Tags |