Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright 2001-2013 Stephen Colebourne
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
 package org.joda.time.chrono;
 
 
Provides time calculations for the era component of time.

Author(s):
Stephen Colebourne
Brian S O'Neill
Since:
1.0
 
 final class GJEraDateTimeField extends BaseDateTimeField {
    
    
Serialization version
 
     @SuppressWarnings("unused")
     private static final long serialVersionUID = 4240986525305515528L;
 
     private final BasicChronology iChronology;

    
Restricted constructor
 
     GJEraDateTimeField(BasicChronology chronology) {
         super(DateTimeFieldType.era());
          = chronology;
     }
 
     public boolean isLenient() {
         return false;
     }

    
Get the Era component of the specified time instant.

Parameters:
instant the time instant in millis to query.
 
     public int get(long instant) {
         if (.getYear(instant) <= 0) {
             return .;
         } else {
             return .;
         }
     }
 
     public String getAsText(int fieldValueLocale locale) {
         return GJLocaleSymbols.forLocale(locale).eraValueToText(fieldValue);
     }

    
Set the Era component of the specified time instant.

Parameters:
instant the time instant in millis to update.
era the era to update the time to.
Returns:
the updated time instant.
Throws:
java.lang.IllegalArgumentException if era is invalid.
 
     public long set(long instantint era) {
         FieldUtils.verifyValueBounds(thisera..);
             
         int oldEra = get(instant);
         if (oldEra != era) {
             int year = .getYear(instant);
             return .setYear(instant, -year);
         } else {
             return instant;
         }
     }
 
     public long set(long instantString textLocale locale) {
         return set(instant, GJLocaleSymbols.forLocale(locale).eraTextToValue(text));
     }
 
     public long roundFloor(long instant) {
         if (get(instant) == .) {
             return .setYear(0, 1);
         } else {
            return .;
        }
    }
    public long roundCeiling(long instant) {
        if (get(instant) == .) {
            return .setYear(0, 1);
        } else {
            return .;
        }
    }
    public long roundHalfFloor(long instant) {
        // In reality, the era is infinite, so there is no halfway point.
        return roundFloor(instant);
    }
    public long roundHalfCeiling(long instant) {
        // In reality, the era is infinite, so there is no halfway point.
        return roundFloor(instant);
    }
    public long roundHalfEven(long instant) {
        // In reality, the era is infinite, so there is no halfway point.
        return roundFloor(instant);
    }
    public DurationField getDurationField() {
        return UnsupportedDurationField.getInstance(DurationFieldType.eras());
    }
        return null;
    }
    public int getMinimumValue() {
        return .;
    }
    public int getMaximumValue() {
        return .;
    }
    public int getMaximumTextLength(Locale locale) {
        return GJLocaleSymbols.forLocale(locale).getEraMaxTextLength();
    }

    
Serialization singleton
    private Object readResolve() {
        return .era();
    }
New to GrepCode? Check out our FAQ X