/** * Instructs the printer to emit a numeric year of century field. * * @param minDigits minimum number of digits to print * @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 appendYearOfCentury(int minDigits, int maxDigits) { return appendDecimal(DateTimeFieldType.yearOfCentury(), minDigits, maxDigits); }
/** * Instructs the printer to emit a numeric year of century field. * * @param minDigits minimum number of digits to print * @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 appendYearOfCentury(int minDigits, int maxDigits) { return appendDecimal(DateTimeFieldType.yearOfCentury(), minDigits, maxDigits); }
protected void appendTwoDigitYear(int pivot, boolean lenient) { builder.appendTwoDigitYear(pivot, lenient); appendNumericField(DateTimeFieldType.yearOfCentury(), 2); } protected void appendWeekyear(int minDigits, int maxDigits) {
protected void appendTwoDigitWeekyear(int pivot, boolean lenient) { builder.appendTwoDigitYear(pivot, lenient); appendNumericField(DateTimeFieldType.yearOfCentury(), 2); } protected void appendWeekOfWeekyear(int digits) {
@Override public DateTimeFieldType[] getDateTimeFields() { return new DateTimeFieldType[] { DateTimeFieldType.year(), DateTimeFieldType.yearOfCentury(), DateTimeFieldType.yearOfEra() }; } private static final long serialVersionUID = 1;
/** * Get the year of century field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField yearOfCentury() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.yearOfCentury(), years()); }
/** * Get the year of century field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField yearOfCentury() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.yearOfCentury(), years()); }
base = JodaTimeUtils.setField(base, DateTimeFieldType.yearOfCentury(), cy); } else if (Character.isDigit(y.charAt(2))) { int decade = Integer.parseInt(y.substring(2, 3));
protected static boolean hasYYMMDD(ReadablePartial base) { if (base == null) { return false; } else { return base.isSupported(DateTimeFieldType.yearOfCentury()) && base.isSupported(DateTimeFieldType.monthOfYear()) && base.isSupported(DateTimeFieldType.dayOfMonth()); } }
protected void assemble(Fields fields) { if (getBase().getZone() == DateTimeZone.UTC) { // Use zero based century and year of century. fields.centuryOfEra = new DividedDateTimeField( ISOYearOfEraDateTimeField.INSTANCE, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField(); fields.yearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, DateTimeFieldType.yearOfCentury()); fields.weekyearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, fields.weekyears, DateTimeFieldType.weekyearOfCentury()); } }
protected void assemble(Fields fields) { if (getBase().getZone() == DateTimeZone.UTC) { // Use zero based century and year of century. fields.centuryOfEra = new DividedDateTimeField( ISOYearOfEraDateTimeField.INSTANCE, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField(); fields.yearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, DateTimeFieldType.yearOfCentury()); fields.weekyearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, fields.weekyears, DateTimeFieldType.weekyearOfCentury()); } }
DateTimeFieldType fieldType = p2.getFieldType(i); if (fieldType == DateTimeFieldType.year()) { if (p.isSupported(DateTimeFieldType.yearOfCentury())) { if (!p.isSupported(DateTimeFieldType.centuryOfEra())) { int yoc = p.get(DateTimeFieldType.yearOfCentury()); int refYear = p2.getValue(i); int century = refYear / 100; y2 -= 100; p = p.without(DateTimeFieldType.yearOfCentury()); p = p.with(DateTimeFieldType.year(), y2); if (p.isSupported(DateTimeFieldType.yearOfCentury()) && p.isSupported(DateTimeFieldType.centuryOfEra())) { int year = p.get(DateTimeFieldType.yearOfCentury()) + p.get(DateTimeFieldType.centuryOfEra())*100; p = p.with(DateTimeFieldType.year(), year); p = p.without(DateTimeFieldType.yearOfCentury()); p = p.without(DateTimeFieldType.centuryOfEra());
DateTimeFieldType fieldType = p2.getFieldType(i); if (fieldType == DateTimeFieldType.year()) { if (p.isSupported(DateTimeFieldType.yearOfCentury())) { if (!p.isSupported(DateTimeFieldType.centuryOfEra())) { int yoc = p.get(DateTimeFieldType.yearOfCentury()); int refYear = p2.getValue(i); int century = refYear / 100; y2 -= 100; p = p.without(DateTimeFieldType.yearOfCentury()); p = p.with(DateTimeFieldType.year(), y2); continue; } else if (fieldType == DateTimeFieldType.yearOfCentury()) { if (p.isSupported(DateTimeFieldType.year())) { continue; if (p.isSupported(DateTimeFieldType.yearOfCentury()) && p.isSupported(DateTimeFieldType.centuryOfEra())) { int year = p.get(DateTimeFieldType.yearOfCentury()) + p.get(DateTimeFieldType.centuryOfEra())*100; p = p.with(DateTimeFieldType.year(), year); p = p.without(DateTimeFieldType.yearOfCentury()); p = p.without(DateTimeFieldType.centuryOfEra());
public static Instant getInstant(Partial p, ZoneId timezone) { if (p == null) return null; int year = p.isSupported(DateTimeFieldType.year())? p.get(DateTimeFieldType.year()):0; if (!p.isSupported(DateTimeFieldType.year())) { if (p.isSupported(DateTimeFieldType.centuryOfEra())) { year += 100*p.get(DateTimeFieldType.centuryOfEra()); } if (p.isSupported(DateTimeFieldType.yearOfCentury())) { year += p.get(DateTimeFieldType.yearOfCentury()); } else if (p.isSupported(DecadeOfCentury)) { year += 10*p.get(DecadeOfCentury); } } int moy = p.isSupported(DateTimeFieldType.monthOfYear())? p.get(DateTimeFieldType.monthOfYear()):1; if (!p.isSupported(DateTimeFieldType.monthOfYear())) { if (p.isSupported(QuarterOfYear)) { moy += 3*(p.get(QuarterOfYear)-1); } } int dom = p.isSupported(DateTimeFieldType.dayOfMonth())? p.get(DateTimeFieldType.dayOfMonth()):1; int hod = p.isSupported(DateTimeFieldType.hourOfDay())? p.get(DateTimeFieldType.hourOfDay()):0; int moh = p.isSupported(DateTimeFieldType.minuteOfHour())? p.get(DateTimeFieldType.minuteOfHour()):0; int som = p.isSupported(DateTimeFieldType.secondOfMinute())? p.get(DateTimeFieldType.secondOfMinute()):0; int msos = p.isSupported(DateTimeFieldType.millisOfSecond())? p.get(DateTimeFieldType.millisOfSecond()):0; return new DateTime(year, moy, dom, hod, moh, som, msos, fromTimezone(timezone)).toInstant(); }
(DividedDateTimeField) fields.centuryOfEra); fields.yearOfCentury = new OffsetDateTimeField( field, DateTimeFieldType.yearOfCentury(), 1);
(DividedDateTimeField) fields.centuryOfEra); fields.yearOfCentury = new OffsetDateTimeField( field, DateTimeFieldType.yearOfCentury(), 1);
isMoreGeneral(msf, DateTimeFieldType.yearOfCentury(), p.getChronology())) { if (p.isSupported(DateTimeFieldType.yearOfCentury())) { int year = p.get(JodaTimeUtils.DecadeOfCentury)*10; p = p.without(JodaTimeUtils.DecadeOfCentury); p = p.with(DateTimeFieldType.yearOfCentury(), year);
(DividedDateTimeField) fields.centuryOfEra); fields.yearOfCentury = new OffsetDateTimeField( field, DateTimeFieldType.yearOfCentury(), 1);
(DividedDateTimeField) fields.centuryOfEra); fields.yearOfCentury = new OffsetDateTimeField( field, DateTimeFieldType.yearOfCentury(), 1);
|| JodaTimeUtils.hasField(base, DateTimeFieldType.yearOfCentury())) { if (JodaTimeUtils.hasField(base, DateTimeFieldType.centuryOfEra())) { builder.appendCenturyOfEra(2, 2); builder.appendDecimal(JodaTimeUtils.DecadeOfCentury, 1, 1); builder.appendLiteral(PAD_FIELD_UNKNOWN); } else if (JodaTimeUtils.hasField(base, DateTimeFieldType.yearOfCentury())) { builder.appendYearOfCentury(2, 2); } else {