what-the-bank/sources/org/threeten/bp/OffsetDateTime.java

569 lines
20 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.threeten.bp;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.Comparator;
import o.AbstractC15502gsH;
import o.AbstractC15514gsj;
import o.AbstractC15535gtF;
import o.C15501gsD;
import o.C15520gsp;
import o.C15521gsq;
import o.C15522gsr;
import o.C15523gss;
import o.C15524gst;
import o.C15554gto;
import o.EnumC15515gsk;
import o.EnumC15528gsx;
import o.EnumC15534gtD;
import o.InterfaceC15536gtL;
import o.InterfaceC15537gtP;
import o.InterfaceC15539gtV;
import o.gsI;
import o.gsN;
import o.gsO;
import o.gsV;
import o.gtG;
import o.gtH;
import o.gtJ;
import o.gtK;
import o.gtM;
import o.gtN;
import o.gtQ;
import o.gtT;
/* loaded from: classes.dex */
public final class OffsetDateTime extends AbstractC15535gtF implements InterfaceC15536gtL, gtJ, Comparable<OffsetDateTime>, Serializable {
private static final long serialVersionUID = 2287754244819255394L;
public C15522gsr dateTime;
public gsI offset;
public static final OffsetDateTime MIN = C15522gsr.MIN.atOffset(gsI.MAX);
public static final OffsetDateTime MAX = C15522gsr.MAX.atOffset(gsI.MIN);
public static final gtQ<OffsetDateTime> FROM = new gtQ<OffsetDateTime>() { // from class: org.threeten.bp.OffsetDateTime.4
@Override // o.gtQ
public final OffsetDateTime queryFrom(gtK gtk) {
return OffsetDateTime.from(gtk);
}
};
private static final Comparator<OffsetDateTime> INSTANT_COMPARATOR = new Comparator<OffsetDateTime>() { // from class: org.threeten.bp.OffsetDateTime.2
@Override // java.util.Comparator
public final int compare(OffsetDateTime offsetDateTime, OffsetDateTime offsetDateTime2) {
int compareLongs = gtG.compareLongs(offsetDateTime.toEpochSecond(), offsetDateTime2.toEpochSecond());
return compareLongs == 0 ? gtG.compareLongs(offsetDateTime.getNano(), offsetDateTime2.getNano()) : compareLongs;
}
};
public static OffsetDateTime now() {
return now(AbstractC15514gsj.systemDefaultZone());
}
public static OffsetDateTime now(AbstractC15502gsH abstractC15502gsH) {
return now(AbstractC15514gsj.system(abstractC15502gsH));
}
public static OffsetDateTime now(AbstractC15514gsj abstractC15514gsj) {
gtG.requireNonNull(abstractC15514gsj, "clock");
C15523gss instant = abstractC15514gsj.instant();
return ofInstant(instant, abstractC15514gsj.getZone().getRules().getOffset(instant));
}
public static OffsetDateTime of(C15520gsp c15520gsp, C15521gsq c15521gsq, gsI gsi) {
return new OffsetDateTime(C15522gsr.of(c15520gsp, c15521gsq), gsi);
}
public static OffsetDateTime of(C15522gsr c15522gsr, gsI gsi) {
return new OffsetDateTime(c15522gsr, gsi);
}
public static OffsetDateTime of(int i, int i2, int i3, int i4, int i5, int i6, int i7, gsI gsi) {
return new OffsetDateTime(C15522gsr.of(i, i2, i3, i4, i5, i6, i7), gsi);
}
public static OffsetDateTime ofInstant(C15523gss c15523gss, AbstractC15502gsH abstractC15502gsH) {
gtG.requireNonNull(c15523gss, "instant");
gtG.requireNonNull(abstractC15502gsH, "zone");
gsI offset = abstractC15502gsH.getRules().getOffset(c15523gss);
return new OffsetDateTime(C15522gsr.ofEpochSecond(c15523gss.getEpochSecond(), c15523gss.getNano(), offset), offset);
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r2v7, types: [org.threeten.bp.OffsetDateTime] */
public static OffsetDateTime from(gtK gtk) {
if (gtk instanceof OffsetDateTime) {
return (OffsetDateTime) gtk;
}
try {
gsI from = gsI.from(gtk);
try {
gtk = of(C15522gsr.from(gtk), from);
return gtk;
} catch (DateTimeException unused) {
return ofInstant(C15523gss.from(gtk), from);
}
} catch (DateTimeException unused2) {
StringBuilder sb = new StringBuilder("Unable to obtain OffsetDateTime from TemporalAccessor: ");
sb.append(gtk);
sb.append(", type ");
sb.append(gtk.getClass().getName());
throw new DateTimeException(sb.toString());
}
}
public static OffsetDateTime parse(CharSequence charSequence) {
return parse(charSequence, C15554gto.ISO_OFFSET_DATE_TIME);
}
public static OffsetDateTime parse(CharSequence charSequence, C15554gto c15554gto) {
gtG.requireNonNull(c15554gto, "formatter");
return (OffsetDateTime) c15554gto.parse(charSequence, FROM);
}
private OffsetDateTime(C15522gsr c15522gsr, gsI gsi) {
this.dateTime = (C15522gsr) gtG.requireNonNull(c15522gsr, "dateTime");
this.offset = (gsI) gtG.requireNonNull(gsi, "offset");
}
private OffsetDateTime with(C15522gsr c15522gsr, gsI gsi) {
return (this.dateTime == c15522gsr && this.offset.equals(gsi)) ? this : new OffsetDateTime(c15522gsr, gsi);
}
@Override // o.gtK
public final boolean isSupported(InterfaceC15537gtP interfaceC15537gtP) {
return (interfaceC15537gtP instanceof EnumC15534gtD) || (interfaceC15537gtP != null && interfaceC15537gtP.isSupportedBy(this));
}
@Override // o.InterfaceC15536gtL
public final boolean isSupported(InterfaceC15539gtV interfaceC15539gtV) {
return interfaceC15539gtV instanceof gtH ? interfaceC15539gtV.isDateBased() || interfaceC15539gtV.isTimeBased() : interfaceC15539gtV != null && interfaceC15539gtV.isSupportedBy(this);
}
@Override // o.gtE, o.gtK
public final gtT range(InterfaceC15537gtP interfaceC15537gtP) {
if (interfaceC15537gtP instanceof EnumC15534gtD) {
if (interfaceC15537gtP == EnumC15534gtD.INSTANT_SECONDS || interfaceC15537gtP == EnumC15534gtD.OFFSET_SECONDS) {
return interfaceC15537gtP.range();
}
return this.dateTime.range(interfaceC15537gtP);
}
return interfaceC15537gtP.rangeRefinedBy(this);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: org.threeten.bp.OffsetDateTime$5, reason: invalid class name */
/* loaded from: classes.dex */
public static /* synthetic */ class AnonymousClass5 {
static final int[] $SwitchMap$org$threeten$bp$temporal$ChronoField;
static {
int[] iArr = new int[EnumC15534gtD.values().length];
$SwitchMap$org$threeten$bp$temporal$ChronoField = iArr;
try {
iArr[EnumC15534gtD.INSTANT_SECONDS.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$org$threeten$bp$temporal$ChronoField[EnumC15534gtD.OFFSET_SECONDS.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
}
}
@Override // o.gtE, o.gtK
public final int get(InterfaceC15537gtP interfaceC15537gtP) {
if (interfaceC15537gtP instanceof EnumC15534gtD) {
int i = AnonymousClass5.$SwitchMap$org$threeten$bp$temporal$ChronoField[((EnumC15534gtD) interfaceC15537gtP).ordinal()];
if (i == 1) {
throw new DateTimeException("Field too large for an int: ".concat(String.valueOf(interfaceC15537gtP)));
}
if (i == 2) {
return getOffset().getTotalSeconds();
}
return this.dateTime.get(interfaceC15537gtP);
}
return super.get(interfaceC15537gtP);
}
@Override // o.gtK
public final long getLong(InterfaceC15537gtP interfaceC15537gtP) {
if (interfaceC15537gtP instanceof EnumC15534gtD) {
int i = AnonymousClass5.$SwitchMap$org$threeten$bp$temporal$ChronoField[((EnumC15534gtD) interfaceC15537gtP).ordinal()];
if (i == 1) {
return toEpochSecond();
}
if (i == 2) {
return getOffset().getTotalSeconds();
}
return this.dateTime.getLong(interfaceC15537gtP);
}
return interfaceC15537gtP.getFrom(this);
}
public final OffsetDateTime withOffsetSameLocal(gsI gsi) {
return with(this.dateTime, gsi);
}
public final OffsetDateTime withOffsetSameInstant(gsI gsi) {
if (gsi.equals(this.offset)) {
return this;
}
return new OffsetDateTime(this.dateTime.plusSeconds(gsi.getTotalSeconds() - this.offset.getTotalSeconds()), gsi);
}
public final int getYear() {
return this.dateTime.getYear();
}
public final int getMonthValue() {
return this.dateTime.getMonthValue();
}
public final EnumC15528gsx getMonth() {
return this.dateTime.getMonth();
}
public final int getDayOfMonth() {
return this.dateTime.getDayOfMonth();
}
public final int getDayOfYear() {
return this.dateTime.getDayOfYear();
}
public final EnumC15515gsk getDayOfWeek() {
return this.dateTime.getDayOfWeek();
}
public final int getHour() {
return this.dateTime.getHour();
}
public final int getMinute() {
return this.dateTime.getMinute();
}
public final int getSecond() {
return this.dateTime.getSecond();
}
public final int getNano() {
return this.dateTime.getNano();
}
@Override // o.AbstractC15535gtF, o.InterfaceC15536gtL
public final OffsetDateTime with(gtJ gtj) {
if ((gtj instanceof C15520gsp) || (gtj instanceof C15521gsq) || (gtj instanceof C15522gsr)) {
return with(this.dateTime.with(gtj), this.offset);
}
if (gtj instanceof C15523gss) {
return ofInstant((C15523gss) gtj, this.offset);
}
if (gtj instanceof gsI) {
return with(this.dateTime, (gsI) gtj);
}
if (gtj instanceof OffsetDateTime) {
return (OffsetDateTime) gtj;
}
return (OffsetDateTime) gtj.adjustInto(this);
}
@Override // o.InterfaceC15536gtL
public final OffsetDateTime with(InterfaceC15537gtP interfaceC15537gtP, long j) {
if (interfaceC15537gtP instanceof EnumC15534gtD) {
EnumC15534gtD enumC15534gtD = (EnumC15534gtD) interfaceC15537gtP;
int i = AnonymousClass5.$SwitchMap$org$threeten$bp$temporal$ChronoField[enumC15534gtD.ordinal()];
if (i == 1) {
return ofInstant(C15523gss.ofEpochSecond(j, getNano()), this.offset);
}
if (i == 2) {
return with(this.dateTime, gsI.ofTotalSeconds(enumC15534gtD.checkValidIntValue(j)));
}
return with(this.dateTime.with(interfaceC15537gtP, j), this.offset);
}
return (OffsetDateTime) interfaceC15537gtP.adjustInto(this, j);
}
public final OffsetDateTime withYear(int i) {
return with(this.dateTime.withYear(i), this.offset);
}
public final OffsetDateTime withMonth(int i) {
return with(this.dateTime.withMonth(i), this.offset);
}
public final OffsetDateTime withDayOfMonth(int i) {
return with(this.dateTime.withDayOfMonth(i), this.offset);
}
public final OffsetDateTime withDayOfYear(int i) {
return with(this.dateTime.withDayOfYear(i), this.offset);
}
public final OffsetDateTime withHour(int i) {
return with(this.dateTime.withHour(i), this.offset);
}
public final OffsetDateTime withMinute(int i) {
return with(this.dateTime.withMinute(i), this.offset);
}
public final OffsetDateTime withSecond(int i) {
return with(this.dateTime.withSecond(i), this.offset);
}
public final OffsetDateTime withNano(int i) {
return with(this.dateTime.withNano(i), this.offset);
}
public final OffsetDateTime truncatedTo(InterfaceC15539gtV interfaceC15539gtV) {
return with(this.dateTime.truncatedTo(interfaceC15539gtV), this.offset);
}
@Override // o.AbstractC15535gtF, o.InterfaceC15536gtL
public final OffsetDateTime plus(gtN gtn) {
return (OffsetDateTime) gtn.addTo(this);
}
@Override // o.InterfaceC15536gtL
public final OffsetDateTime plus(long j, InterfaceC15539gtV interfaceC15539gtV) {
if (interfaceC15539gtV instanceof gtH) {
return with(this.dateTime.plus(j, interfaceC15539gtV), this.offset);
}
return (OffsetDateTime) interfaceC15539gtV.addTo(this, j);
}
public final OffsetDateTime plusYears(long j) {
return with(this.dateTime.plusYears(j), this.offset);
}
public final OffsetDateTime plusMonths(long j) {
return with(this.dateTime.plusMonths(j), this.offset);
}
public final OffsetDateTime plusWeeks(long j) {
return with(this.dateTime.plusWeeks(j), this.offset);
}
public final OffsetDateTime plusDays(long j) {
return with(this.dateTime.plusDays(j), this.offset);
}
public final OffsetDateTime plusHours(long j) {
return with(this.dateTime.plusHours(j), this.offset);
}
public final OffsetDateTime plusMinutes(long j) {
return with(this.dateTime.plusMinutes(j), this.offset);
}
public final OffsetDateTime plusSeconds(long j) {
return with(this.dateTime.plusSeconds(j), this.offset);
}
public final OffsetDateTime plusNanos(long j) {
return with(this.dateTime.plusNanos(j), this.offset);
}
@Override // o.AbstractC15535gtF, o.InterfaceC15536gtL
public final OffsetDateTime minus(gtN gtn) {
return (OffsetDateTime) gtn.subtractFrom(this);
}
@Override // o.AbstractC15535gtF, o.InterfaceC15536gtL
public final OffsetDateTime minus(long j, InterfaceC15539gtV interfaceC15539gtV) {
return j == Long.MIN_VALUE ? plus(Long.MAX_VALUE, interfaceC15539gtV).plus(1L, interfaceC15539gtV) : plus(-j, interfaceC15539gtV);
}
public final OffsetDateTime minusYears(long j) {
return j == Long.MIN_VALUE ? plusYears(Long.MAX_VALUE).plusYears(1L) : plusYears(-j);
}
public final OffsetDateTime minusMonths(long j) {
return j == Long.MIN_VALUE ? plusMonths(Long.MAX_VALUE).plusMonths(1L) : plusMonths(-j);
}
public final OffsetDateTime minusWeeks(long j) {
return j == Long.MIN_VALUE ? plusWeeks(Long.MAX_VALUE).plusWeeks(1L) : plusWeeks(-j);
}
public final OffsetDateTime minusDays(long j) {
return j == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1L) : plusDays(-j);
}
public final OffsetDateTime minusHours(long j) {
return j == Long.MIN_VALUE ? plusHours(Long.MAX_VALUE).plusHours(1L) : plusHours(-j);
}
public final OffsetDateTime minusMinutes(long j) {
return j == Long.MIN_VALUE ? plusMinutes(Long.MAX_VALUE).plusMinutes(1L) : plusMinutes(-j);
}
public final OffsetDateTime minusSeconds(long j) {
return j == Long.MIN_VALUE ? plusSeconds(Long.MAX_VALUE).plusSeconds(1L) : plusSeconds(-j);
}
public final OffsetDateTime minusNanos(long j) {
return j == Long.MIN_VALUE ? plusNanos(Long.MAX_VALUE).plusNanos(1L) : plusNanos(-j);
}
@Override // o.gtE, o.gtK
public final <R> R query(gtQ<R> gtq) {
if (gtq == gtM.chronology()) {
return (R) gsV.INSTANCE;
}
if (gtq == gtM.precision()) {
return (R) gtH.NANOS;
}
if (gtq == gtM.offset() || gtq == gtM.zone()) {
return (R) getOffset();
}
if (gtq == gtM.localDate()) {
return (R) toLocalDate();
}
if (gtq == gtM.localTime()) {
return (R) toLocalTime();
}
if (gtq == gtM.zoneId()) {
return null;
}
return (R) super.query(gtq);
}
@Override // o.gtJ
public final InterfaceC15536gtL adjustInto(InterfaceC15536gtL interfaceC15536gtL) {
return interfaceC15536gtL.with(EnumC15534gtD.EPOCH_DAY, toLocalDate().toEpochDay()).with(EnumC15534gtD.NANO_OF_DAY, toLocalTime().toNanoOfDay()).with(EnumC15534gtD.OFFSET_SECONDS, getOffset().getTotalSeconds());
}
@Override // o.InterfaceC15536gtL
public final long until(InterfaceC15536gtL interfaceC15536gtL, InterfaceC15539gtV interfaceC15539gtV) {
OffsetDateTime from = from(interfaceC15536gtL);
if (interfaceC15539gtV instanceof gtH) {
return this.dateTime.until(from.withOffsetSameInstant(this.offset).dateTime, interfaceC15539gtV);
}
return interfaceC15539gtV.between(this, from);
}
public final gsN atZoneSameInstant(AbstractC15502gsH abstractC15502gsH) {
return gsN.ofInstant(this.dateTime, this.offset, abstractC15502gsH);
}
public final gsN atZoneSimilarLocal(AbstractC15502gsH abstractC15502gsH) {
return gsN.ofLocal(this.dateTime, abstractC15502gsH, this.offset);
}
public final C15520gsp toLocalDate() {
return this.dateTime.toLocalDate();
}
public final C15521gsq toLocalTime() {
return this.dateTime.toLocalTime();
}
public final C15524gst toOffsetTime() {
return C15524gst.of(this.dateTime.toLocalTime(), this.offset);
}
public final gsN toZonedDateTime() {
return gsN.of(this.dateTime, this.offset);
}
public final C15523gss toInstant() {
return this.dateTime.toInstant(this.offset);
}
public final long toEpochSecond() {
return this.dateTime.toEpochSecond(this.offset);
}
@Override // java.lang.Comparable
public final int compareTo(OffsetDateTime offsetDateTime) {
if (getOffset().equals(offsetDateTime.getOffset())) {
return toLocalDateTime().compareTo((gsO<?>) offsetDateTime.toLocalDateTime());
}
int compareLongs = gtG.compareLongs(toEpochSecond(), offsetDateTime.toEpochSecond());
if (compareLongs != 0) {
return compareLongs;
}
int nano = toLocalTime().getNano() - offsetDateTime.toLocalTime().getNano();
return nano == 0 ? toLocalDateTime().compareTo((gsO<?>) offsetDateTime.toLocalDateTime()) : nano;
}
public final boolean isAfter(OffsetDateTime offsetDateTime) {
long epochSecond = toEpochSecond();
long epochSecond2 = offsetDateTime.toEpochSecond();
return epochSecond > epochSecond2 || (epochSecond == epochSecond2 && toLocalTime().getNano() > offsetDateTime.toLocalTime().getNano());
}
public final boolean isBefore(OffsetDateTime offsetDateTime) {
long epochSecond = toEpochSecond();
long epochSecond2 = offsetDateTime.toEpochSecond();
return epochSecond < epochSecond2 || (epochSecond == epochSecond2 && toLocalTime().getNano() < offsetDateTime.toLocalTime().getNano());
}
public final boolean isEqual(OffsetDateTime offsetDateTime) {
return toEpochSecond() == offsetDateTime.toEpochSecond() && toLocalTime().getNano() == offsetDateTime.toLocalTime().getNano();
}
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof OffsetDateTime)) {
return false;
}
OffsetDateTime offsetDateTime = (OffsetDateTime) obj;
return this.dateTime.equals(offsetDateTime.dateTime) && this.offset.equals(offsetDateTime.offset);
}
public final int hashCode() {
return this.dateTime.hashCode() ^ this.offset.hashCode();
}
public final String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.dateTime.toString());
sb.append(this.offset.toString());
return sb.toString();
}
public final String format(C15554gto c15554gto) {
gtG.requireNonNull(c15554gto, "formatter");
return c15554gto.format(this);
}
private Object writeReplace() {
return new C15501gsD((byte) 69, this);
}
private Object readResolve() throws ObjectStreamException {
throw new InvalidObjectException("Deserialization via serialization delegate");
}
public final void writeExternal(DataOutput dataOutput) throws IOException {
this.dateTime.writeExternal(dataOutput);
this.offset.writeExternal(dataOutput);
}
public static OffsetDateTime readExternal(DataInput dataInput) throws IOException {
return of(C15522gsr.readExternal(dataInput), gsI.readExternal(dataInput));
}
public /* synthetic */ OffsetDateTime() {
}
public final C15522gsr toLocalDateTime() {
return this.dateTime;
}
public final gsI getOffset() {
return this.offset;
}
public static Comparator<OffsetDateTime> timeLineOrder() {
return INSTANT_COMPARATOR;
}
}