@Override public DateTimeFieldType[] getDateTimeFields() { return new DateTimeFieldType[] { DateTimeFieldType.centuryOfEra() }; } private static final long serialVersionUID = 1;
/** * Instructs the printer to emit a numeric century of era 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 appendCenturyOfEra(int minDigits, int maxDigits) { return appendSignedDecimal(DateTimeFieldType.centuryOfEra(), minDigits, maxDigits); }
/** * Instructs the printer to emit a numeric century of era 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 appendCenturyOfEra(int minDigits, int maxDigits) { return appendSignedDecimal(DateTimeFieldType.centuryOfEra(), minDigits, maxDigits); }
protected void appendCenturyOfEra(int minDigits, int maxDigits) { builder.appendCenturyOfEra(minDigits, maxDigits); appendNumericField(DateTimeFieldType.centuryOfEra(), minDigits, maxDigits); } protected void appendYearOfEra(int minDigits, int maxDigits) {
/** * Get the century of era field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField centuryOfEra() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.centuryOfEra(), centuries()); }
/** * Get the century of era field for this chronology. * * @return DateTimeField or UnsupportedDateTimeField if unsupported */ public DateTimeField centuryOfEra() { return UnsupportedDateTimeField.getInstance(DateTimeFieldType.centuryOfEra(), centuries()); }
if (Character.isDigit(y.charAt(0)) && Character.isDigit(y.charAt(1))) { int century = Integer.parseInt(y.substring(0, 2)); base = JodaTimeUtils.setField(base, DateTimeFieldType.centuryOfEra(), century);
public static Partial discardMoreSpecificFields(Partial p, DateTimeFieldType d) { Partial res = new Partial(); for (int i = 0; i < p.size(); i++) { DateTimeFieldType fieldType = p.getFieldType(i); if (fieldType.equals(d) || isMoreGeneral(fieldType, d, p.getChronology())) { res = res.with(fieldType, p.getValue(i)); } } if (res.isSupported(JodaTimeUtils.DecadeOfCentury) && !res.isSupported(DateTimeFieldType.centuryOfEra())) { if (p.isSupported(DateTimeFieldType.year())) { res = res.with(DateTimeFieldType.centuryOfEra(), p.get(DateTimeFieldType.year()) / 100); } } return res; }
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()); } }
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); if (!p.isSupported(DateTimeFieldType.centuryOfEra())) { int decade = p.get(JodaTimeUtils.DecadeOfCentury); int refYear = p2.getValue(i); century--; p = p.with(DateTimeFieldType.centuryOfEra(), century); 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());
if (p.isSupported(DateTimeFieldType.centuryOfEra())) { int year = p.get(DateTimeFieldType.centuryOfEra()) * 100 + p.get(JodaTimeUtils.DecadeOfCentury)*10; p = p.without(JodaTimeUtils.DecadeOfCentury); p = p.without(DateTimeFieldType.centuryOfEra()); p = p.with(DateTimeFieldType.year(), year); } else { if (p.isSupported(DateTimeFieldType.centuryOfEra())) { int year = p.get(DateTimeFieldType.centuryOfEra()) * 100; p = p.without(DateTimeFieldType.centuryOfEra()); p = p.with(DateTimeFieldType.year(), year);
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); } else if (p.isSupported(DateTimeFieldType.centuryOfEra())) { continue; continue; } else if (fieldType == DateTimeFieldType.centuryOfEra()) { 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(); }
&& JodaTimeUtils.hasField(p.base, DateTimeFieldType.centuryOfEra())) { Partial p2 = p.base.withField(DateTimeFieldType.centuryOfEra(), p.base.get(DateTimeFieldType.centuryOfEra()) + unsupported.getYears() / 100); p = new PartialTime(p, p2); unsupported = unsupported.withYears(0);
field, fields.eras, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField();
field, fields.eras, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField();
fields.yearOfEra, 99); fields.centuryOfEra = new DividedDateTimeField( field, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField();
fields.yearOfEra, 99); fields.centuryOfEra = new DividedDateTimeField( field, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField();
if (JodaTimeUtils.hasField(base, DateTimeFieldType.centuryOfEra()) || JodaTimeUtils.hasField(base, JodaTimeUtils.DecadeOfCentury) || JodaTimeUtils.hasField(base, DateTimeFieldType.yearOfCentury())) { if (JodaTimeUtils.hasField(base, DateTimeFieldType.centuryOfEra())) { builder.appendCenturyOfEra(2, 2); } else {