@Override public DateTimeFieldType[] getDateTimeFields() { return new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.yearOfCentury(), DateTimeFieldType.yearOfEra() }; } private static final long serialVersionUID = 1;
static int adjustYearForSet(int year) { if (year <= 0) { if (year == 0) { throw new IllegalFieldValueException (DateTimeFieldType.year(), Integer.valueOf(year), null, null); } year++; } return year; }
/** * Instructs the printer to emit a numeric year field. * * @param minDigits minimum number of digits to <i>print</i> * @param maxDigits maximum number of digits to <i>parse</i>, or the estimated * maximum number of digits to print * @return this DateTimeFormatterBuilder, for chaining */ public DateTimeFormatterBuilder appendYear(int minDigits, int maxDigits) { return appendSignedDecimal(DateTimeFieldType.year(), minDigits, maxDigits); }
/** * Restricted constructor. * * @param chronology the chronology this field belongs to */ BasicYearDateTimeField(BasicChronology chronology) { super(DateTimeFieldType.year(), chronology.getAverageMillisPerYear()); iChronology = chronology; }
protected void appendYear(int minDigits, int maxDigits) { builder.appendYear(minDigits, maxDigits); appendNumericField(DateTimeFieldType.year(), minDigits, maxDigits); } protected void appendTwoDigitYear(int pivot, boolean lenient) {
/** * Get the year field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField year() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.year(), years()); }
@Override public SUTime.Time resolve(SUTime.Time t, int flags) { Partial p = (t != null)? t.getJodaTimePartial():null; if (p != null) { if (JodaTimeUtils.hasField(p, DateTimeFieldType.year())) { int year = p.get(DateTimeFieldType.year()); SUTime.Time resolved = resolveWithYear(year); if (resolved != null) { return resolved; } } } return this; }
/** * Get the year field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField year() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.year(), years()); }
public long set(long millis, int value) { FieldUtils.verifyValueBounds(this, value, iMinValue, getMaximumValue()); if (value <= iSkip) { if (value == iSkip) { throw new IllegalFieldValueException (DateTimeFieldType.year(), Integer.valueOf(value), null, null); } value++; } return super.set(millis, value); }
public long set(long millis, int value) { FieldUtils.verifyValueBounds(this, value, iMinValue, getMaximumValue()); if (value <= iSkip) { if (value == iSkip) { throw new IllegalFieldValueException (DateTimeFieldType.year(), Integer.valueOf(value), null, null); } value++; } return super.set(millis, value); }
public int getMaximumValue(ReadablePartial partial, int[] values) { int size = partial.size(); for (int i = 0; i < size; i++) { if (partial.getFieldType(i) == DateTimeFieldType.year()) { int year = values[i]; return iChronology.getDaysInYear(year); } } return iChronology.getDaysInYearMax(); }
public int getMaximumValue(ReadablePartial partial, int[] values) { int size = partial.size(); for (int i = 0; i < size; i++) { if (partial.getFieldType(i) == DateTimeFieldType.year()) { int year = values[i]; return iChronology.getDaysInYear(year); } } return iChronology.getDaysInYearMax(); }
public int getMaximumValue(ReadablePartial partial) { if (partial.isSupported(DateTimeFieldType.monthOfYear())) { int month = partial.get(DateTimeFieldType.monthOfYear()); if (partial.isSupported(DateTimeFieldType.year())) { int year = partial.get(DateTimeFieldType.year()); return iChronology.getDaysInYearMonth(year, month); } return iChronology.getDaysInMonthMax(month); } return getMaximumValue(); }
protected static boolean hasYYYYMMDD(ReadablePartial base) { if (base == null) { return false; } else { return base.isSupported(DateTimeFieldType.year()) && base.isSupported(DateTimeFieldType.monthOfYear()) && base.isSupported(DateTimeFieldType.dayOfMonth()); } }
public int getMaximumValue(ReadablePartial partial) { if (partial.isSupported(DateTimeFieldType.monthOfYear())) { int month = partial.get(DateTimeFieldType.monthOfYear()); if (partial.isSupported(DateTimeFieldType.year())) { int year = partial.get(DateTimeFieldType.year()); return iChronology.getDaysInYearMonth(year, month); } return iChronology.getDaysInMonthMax(month); } return getMaximumValue(); }
private void initBase() { if (era >= 0 ) base = JodaTimeUtils.setField(base, DateTimeFieldType.era(), era); if (year >= 0) base = JodaTimeUtils.setField(base, DateTimeFieldType.year(), year); if (month >= 0) base = JodaTimeUtils.setField(base, DateTimeFieldType.monthOfYear(), month); if (day >= 0) base = JodaTimeUtils.setField(base, DateTimeFieldType.dayOfMonth(), day); }
public static Partial withWeekYear(Partial p) { Partial res = new Partial(); for (int i = 0; i < p.size(); i++) { DateTimeFieldType fieldType = p.getFieldType(i); if (fieldType == DateTimeFieldType.year()) { res = res.with(DateTimeFieldType.weekyear(), p.getValue(i)); } else { res = res.with(fieldType, p.getValue(i)); } } return res; }
public static Partial resolveWeek(Partial p) { // Figure out week if (p.isSupported(DateTimeFieldType.dayOfMonth()) && p.isSupported(DateTimeFieldType.monthOfYear()) && p.isSupported(DateTimeFieldType.year())) { Instant t = getInstant(p); // return getPartial(t.toInstant(), p.without(DateTimeFieldType.dayOfMonth()).without(DateTimeFieldType.monthOfYear()).with(DateTimeFieldType.weekOfWeekyear(), 1)); return getPartial(t.toInstant(), p.with(DateTimeFieldType.weekOfWeekyear(), 1)); } else return p; }