ISOChronology.java 4.42 KB
package org.joda.time.chrono;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.joda.time.Chronology;
import org.joda.time.DateTimeField;
import org.joda.time.DateTimeFieldType;
import org.joda.time.DateTimeZone;
import org.joda.time.field.DividedDateTimeField;
import org.joda.time.field.RemainderDateTimeField;
import uv;

public final class ISOChronology
  extends AssembledChronology
{
  private static final ISOChronology a;
  private static final ISOChronology[] b;
  private static final Map<DateTimeZone, ISOChronology> c = new HashMap();
  private static final long serialVersionUID = -6212696554273812441L;
  
  static
  {
    b = new ISOChronology[64];
    a = new ISOChronology(GregorianChronology.getInstanceUTC());
    c.put(DateTimeZone.UTC, a);
  }
  
  private ISOChronology(Chronology paramChronology)
  {
    super(paramChronology, null);
  }
  
  public static ISOChronology getInstance()
  {
    return getInstance(DateTimeZone.getDefault());
  }
  
  public static ISOChronology getInstance(DateTimeZone paramDateTimeZone)
  {
    DateTimeZone localDateTimeZone = paramDateTimeZone;
    if (paramDateTimeZone == null) {
      localDateTimeZone = DateTimeZone.getDefault();
    }
    int i = System.identityHashCode(localDateTimeZone) & 0x3F;
    paramDateTimeZone = b[i];
    if ((paramDateTimeZone != null) && (paramDateTimeZone.getZone() == localDateTimeZone)) {
      return paramDateTimeZone;
    }
    synchronized (c)
    {
      ISOChronology localISOChronology = (ISOChronology)c.get(localDateTimeZone);
      paramDateTimeZone = localISOChronology;
      if (localISOChronology == null)
      {
        paramDateTimeZone = new ISOChronology(ZonedChronology.getInstance(a, localDateTimeZone));
        c.put(localDateTimeZone, paramDateTimeZone);
      }
      b[i] = paramDateTimeZone;
      return paramDateTimeZone;
    }
  }
  
  public static ISOChronology getInstanceUTC()
  {
    return a;
  }
  
  private Object writeReplace()
  {
    return new a(getZone());
  }
  
  protected final void assemble(AssembledChronology.Fields paramFields)
  {
    if (getBase().getZone() == DateTimeZone.UTC)
    {
      paramFields.centuryOfEra = new DividedDateTimeField(uv.a, DateTimeFieldType.centuryOfEra(), 100);
      paramFields.yearOfCentury = new RemainderDateTimeField((DividedDateTimeField)paramFields.centuryOfEra, DateTimeFieldType.yearOfCentury());
      paramFields.weekyearOfCentury = new RemainderDateTimeField((DividedDateTimeField)paramFields.centuryOfEra, DateTimeFieldType.weekyearOfCentury());
      paramFields.centuries = paramFields.centuryOfEra.getDurationField();
    }
  }
  
  public final boolean equals(Object paramObject)
  {
    return super.equals(paramObject);
  }
  
  public final int hashCode()
  {
    return "ISO".hashCode() * 11 + getZone().hashCode();
  }
  
  public final String toString()
  {
    String str = "ISOChronology";
    DateTimeZone localDateTimeZone = getZone();
    if (localDateTimeZone != null) {
      str = "ISOChronology" + '[' + localDateTimeZone.getID() + ']';
    }
    return str;
  }
  
  public final Chronology withUTC()
  {
    return a;
  }
  
  public final Chronology withZone(DateTimeZone paramDateTimeZone)
  {
    DateTimeZone localDateTimeZone = paramDateTimeZone;
    if (paramDateTimeZone == null) {
      localDateTimeZone = DateTimeZone.getDefault();
    }
    if (localDateTimeZone == getZone()) {
      return this;
    }
    return getInstance(localDateTimeZone);
  }
  
  static final class a
    implements Serializable
  {
    private static final long serialVersionUID = -6212696554273812441L;
    private transient DateTimeZone a;
    
    a(DateTimeZone paramDateTimeZone)
    {
      this.a = paramDateTimeZone;
    }
    
    private void readObject(ObjectInputStream paramObjectInputStream)
      throws IOException, ClassNotFoundException
    {
      this.a = ((DateTimeZone)paramObjectInputStream.readObject());
    }
    
    private Object readResolve()
    {
      return ISOChronology.getInstance(this.a);
    }
    
    private void writeObject(ObjectOutputStream paramObjectOutputStream)
      throws IOException
    {
      paramObjectOutputStream.writeObject(this.a);
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/org/joda/time/chrono/ISOChronology.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */