1 16 package org.joda.time.convert; 17 18 import org.joda.time.Chronology; 19 import org.joda.time.DateTimeUtils; 20 import org.joda.time.DateTimeZone; 21 import org.joda.time.ReadablePartial; 22 23 29 class ReadablePartialConverter extends AbstractConverter 30 implements PartialConverter { 31 32 35 static final ReadablePartialConverter INSTANCE = new ReadablePartialConverter(); 36 37 40 protected ReadablePartialConverter() { 41 super(); 42 } 43 44 52 public Chronology getChronology(Object object, DateTimeZone zone) { 53 return getChronology(object, (Chronology) null).withZone(zone); 54 } 55 56 66 public Chronology getChronology(Object object, Chronology chrono) { 67 if (chrono == null) { 68 chrono = ((ReadablePartial) object).getChronology(); 69 chrono = DateTimeUtils.getChronology(chrono); 70 } 71 return chrono; 72 } 73 74 86 public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono) { 87 ReadablePartial input = (ReadablePartial) object; 88 int size = fieldSource.size(); 89 int[] values = new int[size]; 90 for (int i = 0; i < size; i++) { 91 values[i] = input.get(fieldSource.getFieldType(i)); 92 } 93 chrono.validate(fieldSource, values); 94 return values; 95 } 96 97 103 public Class getSupportedType() { 104 return ReadablePartial.class; 105 } 106 107 } 108 | Popular Tags |