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.PeriodType; 22 import org.joda.time.ReadablePartial; 23 import org.joda.time.chrono.ISOChronology; 24 import org.joda.time.format.DateTimeFormatter; 25 26 32 public abstract class AbstractConverter implements Converter { 33 34 37 protected AbstractConverter() { 38 super(); 39 } 40 41 51 public long getInstantMillis(Object object, Chronology chrono) { 52 return DateTimeUtils.currentTimeMillis(); 53 } 54 55 66 public Chronology getChronology(Object object, DateTimeZone zone) { 67 return ISOChronology.getInstance(zone); 68 } 69 70 81 public Chronology getChronology(Object object, Chronology chrono) { 82 return DateTimeUtils.getChronology(chrono); 83 } 84 85 100 public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono) { 101 long instant = getInstantMillis(object, chrono); 102 return chrono.get(fieldSource, instant); 103 } 104 105 121 public int[] getPartialValues(ReadablePartial fieldSource, 122 Object object, Chronology chrono, DateTimeFormatter parser) { 123 return getPartialValues(fieldSource, object, chrono); 124 } 125 126 133 public PeriodType getPeriodType(Object object) { 134 return PeriodType.standard(); 135 } 136 137 147 public boolean isReadableInterval(Object object, Chronology chrono) { 148 return false; 149 } 150 151 157 public String toString() { 158 return "Converter[" + (getSupportedType() == null ? "null" : getSupportedType().getName()) + "]"; 159 } 160 161 } 162 | Popular Tags |