List of usage examples for org.joda.time DateTimeConstants BCE
int BCE
To view the source code for org.joda.time DateTimeConstants BCE.
Click Source Link
From source file:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.TimeMLDateTimePoint.java
License:Open Source License
/** * Updates date representation (year, month, day) in openedFields. All fields greater than changedGranularity * will be opened. Field that contains changedGranularity will be overwritten when * skipOverwritingChangedOne == false; * <br><br>// www . j a v a2 s. c o m * When flag releaseMaskAtLowerGranularities is set, the input flag skipRemovingMaskFromChangedOne will be used * to decide, whether mask will be removed from the field associated with changedGranularity. */ private void updateDateRepresentation(Granulaarsus changedGranularity, String label, boolean skipOverwritingChangedOne, boolean setOrAddOperation) { // Memorize modification of the field (this.modifiedGrans).put(changedGranularity, "1"); if (label == null) { if ((isModified(Granulaarsus.DAY_OF_WEEK) && isModified(Granulaarsus.WEEK_OF_YEAR)) && (changedGranularity == Granulaarsus.WEEK_OF_YEAR || changedGranularity == Granulaarsus.DAY_OF_WEEK)) { // Only if week/month is not masked if (!(this.maskedFields).containsKey(VALUE_FIELD.MONTH_OR_WEEK)) { // If week has been set, and now day of week is added, switch to month-based representation // month-based representation is always prefered over week-based one (this.openedFields).put(VALUE_FIELD.MONTH_OR_WEEK, normalizeByAddingZeroes( VALUE_FIELD.MONTH_OR_WEEK, (this.underlyingDate).getMonthOfYear())); (this.openedFields).put(VALUE_FIELD.DAY, normalizeByAddingZeroes(VALUE_FIELD.DAY, (this.underlyingDate).getDayOfMonth())); } } } // Usual cases: full year, month, day for (int i = 0; i < 3; i++) { VALUE_FIELD field = valueFieldsInOrder[i]; if (field.matchesGranularity(changedGranularity)) { // // A) Open all upper granularities // int j = i; while (j > -1) { VALUE_FIELD upperOrSameField = valueFieldsInOrder[j]; if (j == i && skipOverwritingChangedOne) { j--; continue; } if (upperOrSameField == VALUE_FIELD.YEAR) { String yearStr = String.valueOf((this.underlyingDate).getYear()); // If the year is BeforeCommonEra, remove minus; "BC" should be sufficient; if (yearStr.startsWith("-")) { yearStr = yearStr.substring(1); } yearStr = normalizeByAddingZeroes(VALUE_FIELD.YEAR, yearStr); if (((this.underlyingDate).era()).get() == DateTimeConstants.BCE) { yearStr = "BC" + yearStr; } (this.openedFields).put(upperOrSameField, yearStr); } if (upperOrSameField == VALUE_FIELD.MONTH_OR_WEEK) { if ((isModified(Granulaarsus.WEEK_OF_YEAR) && !isModified(Granulaarsus.DAY_OF_WEEK)) || (isModified(Granulaarsus.DAY_OF_WEEK) && !isModified(Granulaarsus.WEEK_OF_YEAR)) || (isModified(Granulaarsus.DAY_OF_WEEK) && isModified(Granulaarsus.WEEK_OF_YEAR) && (this.maskedFields).containsKey(VALUE_FIELD.MONTH_OR_WEEK)) || (isModified(Granulaarsus.DAY_OF_WEEK) && isModified(Granulaarsus.WEEK_OF_YEAR) && changedGranularity == Granulaarsus.DAY_OF_WEEK && label != null) ) { (this.openedFields).put(upperOrSameField, "W" + normalizeByAddingZeroes(VALUE_FIELD.MONTH_OR_WEEK, (this.underlyingDate).getWeekOfWeekyear())); if ((this.maskedFields).containsKey(upperOrSameField)) { (this.maskedFields).put(upperOrSameField, "WXX"); } } else { (this.openedFields).put(upperOrSameField, normalizeByAddingZeroes( VALUE_FIELD.MONTH_OR_WEEK, (this.underlyingDate).getMonthOfYear())); if ((this.maskedFields).containsKey(upperOrSameField)) { (this.maskedFields).put(upperOrSameField, "XX"); } } } if (upperOrSameField == VALUE_FIELD.DAY) { if ((isModified(Granulaarsus.WEEK_OF_YEAR) && !isModified(Granulaarsus.DAY_OF_WEEK)) || (isModified(Granulaarsus.DAY_OF_WEEK) && !isModified(Granulaarsus.WEEK_OF_YEAR)) || (isModified(Granulaarsus.DAY_OF_WEEK) && isModified(Granulaarsus.WEEK_OF_YEAR) && (this.maskedFields).containsKey(VALUE_FIELD.MONTH_OR_WEEK))) { (this.openedFields).put(upperOrSameField, String.valueOf((this.underlyingDate).getDayOfWeek())); } else { (this.openedFields).put(upperOrSameField, normalizeByAddingZeroes(VALUE_FIELD.DAY, (this.underlyingDate).getDayOfMonth())); } } j--; } break; } } // century of era has been set: cut year to century level if (isModified(Granulaarsus.CENTURY_OF_ERA) && !isModified(Granulaarsus.YEAR) && !isModified(Granulaarsus.YEAR_OF_CENTURY) && (this.openedFields).containsKey(VALUE_FIELD.YEAR) && (this.openedFields).get(VALUE_FIELD.YEAR).matches("(BC)?\\d{2,4}")) { String newYearVal = String.valueOf((this.underlyingDate).getCenturyOfEra()); if (newYearVal.length() == 1) { newYearVal = "0" + newYearVal; } if (((this.underlyingDate).era()).get() == DateTimeConstants.BCE) { newYearVal = "BC" + newYearVal; } openedFields.put(VALUE_FIELD.YEAR, newYearVal); } // Manage masks on fields: open or close fields, if necessary manageMaskedFields(changedGranularity, label, skipOverwritingChangedOne, setOrAddOperation); }