1 16 package org.joda.time.field; 17 18 import org.joda.time.DateTimeField; 19 20 31 public class StrictDateTimeField extends DelegatedDateTimeField { 32 33 private static final long serialVersionUID = 3154803964207950910L; 34 35 40 public static DateTimeField getInstance(DateTimeField field) { 41 if (field == null) { 42 return null; 43 } 44 if (field instanceof LenientDateTimeField) { 45 field = ((LenientDateTimeField)field).getWrappedField(); 46 } 47 if (!field.isLenient()) { 48 return field; 49 } 50 return new StrictDateTimeField(field); 51 } 52 53 protected StrictDateTimeField(DateTimeField field) { 54 super(field); 55 } 56 57 public final boolean isLenient() { 58 return false; 59 } 60 61 66 public long set(long instant, int value) { 67 FieldUtils.verifyValueBounds 68 (this, value, getMinimumValue(instant), getMaximumValue(instant)); 69 return super.set(instant, value); 70 } 71 } 72 | Popular Tags |