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.ReadableInstant; 22 import org.joda.time.chrono.ISOChronology; 23 24 30 class ReadableInstantConverter extends AbstractConverter 31 implements InstantConverter, PartialConverter { 32 33 36 static final ReadableInstantConverter INSTANCE = new ReadableInstantConverter(); 37 38 41 protected ReadableInstantConverter() { 42 super(); 43 } 44 45 57 public Chronology getChronology(Object object, DateTimeZone zone) { 58 Chronology chrono = ((ReadableInstant) object).getChronology(); 59 if (chrono == null) { 60 return ISOChronology.getInstance(zone); 61 } 62 DateTimeZone chronoZone = chrono.getZone(); 63 if (chronoZone != zone) { 64 chrono = chrono.withZone(zone); 65 if (chrono == null) { 66 return ISOChronology.getInstance(zone); 67 } 68 } 69 return chrono; 70 } 71 72 82 public Chronology getChronology(Object object, Chronology chrono) { 83 if (chrono == null) { 84 chrono = ((ReadableInstant) object).getChronology(); 85 chrono = DateTimeUtils.getChronology(chrono); 86 } 87 return chrono; 88 } 89 90 99 public long getInstantMillis(Object object, Chronology chrono) { 100 return ((ReadableInstant) object).getMillis(); 101 } 102 103 109 public Class getSupportedType() { 110 return ReadableInstant.class; 111 } 112 113 } 114 | Popular Tags |