2
* Copyright 2001-2005 Stephen Colebourne
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
16
package org.joda.time.chrono;
18
import java.util.Locale;
20
import org.joda.time.DateTimeConstants;
21
import org.joda.time.DateTimeFieldType;
22
import org.joda.time.DurationField;
23
import org.joda.time.DurationFieldType;
24
import org.joda.time.IllegalFieldValueException;
25
import org.joda.time.field.BaseDateTimeField;
26
import org.joda.time.field.FieldUtils;
27
import org.joda.time.field.UnsupportedDurationField;
30
* Provides time calculations for the coptic era component of time.
32
* @author Brian S O'Neill
33
* @author Stephen Colebourne
34
* @since 1.2, refactored from CopticEraDateTimeField
36
final class BasicSingleEraDateTimeField extends BaseDateTimeField {
39
* Value of the era, which will be the same as DateTimeConstants.CE.
41
private static final int ERA_VALUE = DateTimeConstants.CE;
43
* Text value of the era.
45
private final String iEraText;
48
* Restricted constructor.
50
BasicSingleEraDateTimeField(String text) {
51
super(DateTimeFieldType.era());
56
public boolean isLenient() {
61
public int get(long instant) {
66
public long set(long instant, int era) {
67
FieldUtils.verifyValueBounds(this, era, ERA_VALUE, ERA_VALUE);
72
public long set(long instant, String text, Locale locale) {
73
if (iEraText.equals(text) == false && "1".equals(text) == false) {
74
throw new IllegalFieldValueException(DateTimeFieldType.era(), text);
80
public long roundFloor(long instant) {
81
return Long.MIN_VALUE;
85
public long roundCeiling(long instant) {
86
return Long.MAX_VALUE;
90
public long roundHalfFloor(long instant) {
91
return Long.MIN_VALUE;
95
public long roundHalfCeiling(long instant) {
96
return Long.MIN_VALUE;
100
public long roundHalfEven(long instant) {
101
return Long.MIN_VALUE;
105
public DurationField getDurationField() {
106
return UnsupportedDurationField.getInstance(DurationFieldType.eras());
110
public DurationField getRangeDurationField() {
115
public int getMinimumValue() {
120
public int getMaximumValue() {
125
public String getAsText(int fieldValue, Locale locale) {
130
public int getMaximumTextLength(Locale locale) {
131
return iEraText.length();