Search in sources :

Example 1 with OffsetDateTimeField

use of org.joda.time.field.OffsetDateTimeField in project joda-time by JodaOrg.

the class BuddhistChronology method assemble.

protected void assemble(Fields fields) {
    if (getParam() == null) {
        // force init as used below
        fields.eras = UnsupportedDurationField.getInstance(DurationFieldType.eras());
        // julian chrono removed zero, but we need to put it back
        DateTimeField field = fields.year;
        fields.year = new OffsetDateTimeField(new SkipUndoDateTimeField(this, field), BUDDHIST_OFFSET);
        // one era, so yearOfEra is the same
        field = fields.yearOfEra;
        fields.yearOfEra = new DelegatedDateTimeField(fields.year, fields.eras, DateTimeFieldType.yearOfEra());
        // julian chrono removed zero, but we need to put it back
        field = fields.weekyear;
        fields.weekyear = new OffsetDateTimeField(new SkipUndoDateTimeField(this, field), BUDDHIST_OFFSET);
        field = new OffsetDateTimeField(fields.yearOfEra, 99);
        fields.centuryOfEra = new DividedDateTimeField(field, fields.eras, DateTimeFieldType.centuryOfEra(), 100);
        fields.centuries = fields.centuryOfEra.getDurationField();
        field = new RemainderDateTimeField((DividedDateTimeField) fields.centuryOfEra);
        fields.yearOfCentury = new OffsetDateTimeField(field, DateTimeFieldType.yearOfCentury(), 1);
        field = new RemainderDateTimeField(fields.weekyear, fields.centuries, DateTimeFieldType.weekyearOfCentury(), 100);
        fields.weekyearOfCentury = new OffsetDateTimeField(field, DateTimeFieldType.weekyearOfCentury(), 1);
        fields.era = ERA_FIELD;
    }
}
Also used : OffsetDateTimeField(org.joda.time.field.OffsetDateTimeField) SkipUndoDateTimeField(org.joda.time.field.SkipUndoDateTimeField) RemainderDateTimeField(org.joda.time.field.RemainderDateTimeField) OffsetDateTimeField(org.joda.time.field.OffsetDateTimeField) SkipUndoDateTimeField(org.joda.time.field.SkipUndoDateTimeField) RemainderDateTimeField(org.joda.time.field.RemainderDateTimeField) DelegatedDateTimeField(org.joda.time.field.DelegatedDateTimeField) DateTimeField(org.joda.time.DateTimeField) DividedDateTimeField(org.joda.time.field.DividedDateTimeField) DelegatedDateTimeField(org.joda.time.field.DelegatedDateTimeField) DividedDateTimeField(org.joda.time.field.DividedDateTimeField)

Example 2 with OffsetDateTimeField

use of org.joda.time.field.OffsetDateTimeField in project joda-time by JodaOrg.

the class BasicChronology method assemble.

protected void assemble(Fields fields) {
    // First copy fields that are the same for all Gregorian and Julian
    // chronologies.
    fields.millis = cMillisField;
    fields.seconds = cSecondsField;
    fields.minutes = cMinutesField;
    fields.hours = cHoursField;
    fields.halfdays = cHalfdaysField;
    fields.days = cDaysField;
    fields.weeks = cWeeksField;
    fields.millisOfSecond = cMillisOfSecondField;
    fields.millisOfDay = cMillisOfDayField;
    fields.secondOfMinute = cSecondOfMinuteField;
    fields.secondOfDay = cSecondOfDayField;
    fields.minuteOfHour = cMinuteOfHourField;
    fields.minuteOfDay = cMinuteOfDayField;
    fields.hourOfDay = cHourOfDayField;
    fields.hourOfHalfday = cHourOfHalfdayField;
    fields.clockhourOfDay = cClockhourOfDayField;
    fields.clockhourOfHalfday = cClockhourOfHalfdayField;
    fields.halfdayOfDay = cHalfdayOfDayField;
    // Now create fields that have unique behavior for Gregorian and Julian
    // chronologies.
    fields.year = new BasicYearDateTimeField(this);
    fields.yearOfEra = new GJYearOfEraDateTimeField(fields.year, this);
    // Define one-based centuryOfEra and yearOfCentury.
    DateTimeField field = new OffsetDateTimeField(fields.yearOfEra, 99);
    fields.centuryOfEra = new DividedDateTimeField(field, DateTimeFieldType.centuryOfEra(), 100);
    fields.centuries = fields.centuryOfEra.getDurationField();
    field = new RemainderDateTimeField((DividedDateTimeField) fields.centuryOfEra);
    fields.yearOfCentury = new OffsetDateTimeField(field, DateTimeFieldType.yearOfCentury(), 1);
    fields.era = new GJEraDateTimeField(this);
    fields.dayOfWeek = new GJDayOfWeekDateTimeField(this, fields.days);
    fields.dayOfMonth = new BasicDayOfMonthDateTimeField(this, fields.days);
    fields.dayOfYear = new BasicDayOfYearDateTimeField(this, fields.days);
    fields.monthOfYear = new GJMonthOfYearDateTimeField(this);
    fields.weekyear = new BasicWeekyearDateTimeField(this);
    fields.weekOfWeekyear = new BasicWeekOfWeekyearDateTimeField(this, fields.weeks);
    field = new RemainderDateTimeField(fields.weekyear, fields.centuries, DateTimeFieldType.weekyearOfCentury(), 100);
    fields.weekyearOfCentury = new OffsetDateTimeField(field, DateTimeFieldType.weekyearOfCentury(), 1);
    // The remaining (imprecise) durations are available from the newly
    // created datetime fields.
    fields.years = fields.year.getDurationField();
    fields.months = fields.monthOfYear.getDurationField();
    fields.weekyears = fields.weekyear.getDurationField();
}
Also used : OffsetDateTimeField(org.joda.time.field.OffsetDateTimeField) RemainderDateTimeField(org.joda.time.field.RemainderDateTimeField) ZeroIsMaxDateTimeField(org.joda.time.field.ZeroIsMaxDateTimeField) PreciseDateTimeField(org.joda.time.field.PreciseDateTimeField) OffsetDateTimeField(org.joda.time.field.OffsetDateTimeField) RemainderDateTimeField(org.joda.time.field.RemainderDateTimeField) DateTimeField(org.joda.time.DateTimeField) DividedDateTimeField(org.joda.time.field.DividedDateTimeField) DividedDateTimeField(org.joda.time.field.DividedDateTimeField)

Aggregations

DateTimeField (org.joda.time.DateTimeField)2 DividedDateTimeField (org.joda.time.field.DividedDateTimeField)2 OffsetDateTimeField (org.joda.time.field.OffsetDateTimeField)2 RemainderDateTimeField (org.joda.time.field.RemainderDateTimeField)2 DelegatedDateTimeField (org.joda.time.field.DelegatedDateTimeField)1 PreciseDateTimeField (org.joda.time.field.PreciseDateTimeField)1 SkipUndoDateTimeField (org.joda.time.field.SkipUndoDateTimeField)1 ZeroIsMaxDateTimeField (org.joda.time.field.ZeroIsMaxDateTimeField)1