2021-12-17 22:01:24 +00:00
package b.g.a.c.g0.u ;
2021-08-09 22:50:52 +00:00
2021-12-17 22:01:24 +00:00
import b.g.a.a.i ;
import b.g.a.c.d ;
import b.g.a.c.g0.i ;
import b.g.a.c.i0.r ;
import b.g.a.c.n ;
import b.g.a.c.w ;
import b.g.a.c.x ;
import b.g.a.c.z.a ;
2021-08-09 22:50:52 +00:00
import com.fasterxml.jackson.databind.JsonMappingException ;
import java.io.IOException ;
import java.text.DateFormat ;
import java.text.SimpleDateFormat ;
import java.util.Date ;
import java.util.Objects ;
import java.util.TimeZone ;
import java.util.concurrent.atomic.AtomicReference ;
2022-03-01 22:12:19 +00:00
/* compiled from: DateTimeSerializerBase.java */
2022-03-07 09:36:12 +00:00
/* loaded from: classes3.dex */
2021-08-09 22:50:52 +00:00
public abstract class l < T > extends p0 < T > implements i {
public final DateFormat _customFormat ;
public final AtomicReference < DateFormat > _reusedCustomFormat ;
public final Boolean _useTimestamp ;
public l ( Class < T > cls , Boolean bool , DateFormat dateFormat ) {
super ( cls ) ;
this . _useTimestamp = bool ;
this . _customFormat = dateFormat ;
this . _reusedCustomFormat = dateFormat = = null ? null : new AtomicReference < > ( ) ;
}
2021-12-17 22:01:24 +00:00
@Override // b.g.a.c.g0.i
2021-08-09 22:50:52 +00:00
public n < ? > a ( x xVar , d dVar ) throws JsonMappingException {
TimeZone timeZone ;
i . d l = l ( xVar , dVar , this . _handledType ) ;
if ( l = = null ) {
return this ;
}
i . c e = l . e ( ) ;
if ( e . f ( ) ) {
return r ( Boolean . TRUE , null ) ;
}
if ( l . h ( ) ) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat ( l . d ( ) , l . g ( ) ? l . c ( ) : xVar . _config . _base . _locale ) ;
if ( l . j ( ) ) {
timeZone = l . f ( ) ;
} else {
timeZone = xVar . _config . _base . _timeZone ;
if ( timeZone = = null ) {
2021-12-17 22:01:24 +00:00
timeZone = a . j ;
2021-08-09 22:50:52 +00:00
}
}
simpleDateFormat . setTimeZone ( timeZone ) ;
return r ( Boolean . FALSE , simpleDateFormat ) ;
}
boolean g = l . g ( ) ;
boolean j = l . j ( ) ;
boolean z2 = true ;
boolean z3 = e = = i . c . STRING ;
if ( ! g & & ! j & & ! z3 ) {
return this ;
}
DateFormat dateFormat = xVar . _config . _base . _dateFormat ;
if ( dateFormat instanceof r ) {
r rVar = ( r ) dateFormat ;
if ( l . g ( ) ) {
rVar = rVar . l ( l . c ( ) ) ;
}
if ( l . j ( ) ) {
rVar = rVar . m ( l . f ( ) ) ;
}
return r ( Boolean . FALSE , rVar ) ;
}
if ( ! ( dateFormat instanceof SimpleDateFormat ) ) {
xVar . g ( this . _handledType , String . format ( " Configured `DateFormat` (%s) not a `SimpleDateFormat`; cannot configure `Locale` or `TimeZone` " , dateFormat . getClass ( ) . getName ( ) ) ) ;
}
SimpleDateFormat simpleDateFormat2 = ( SimpleDateFormat ) dateFormat ;
SimpleDateFormat simpleDateFormat3 = g ? new SimpleDateFormat ( simpleDateFormat2 . toPattern ( ) , l . c ( ) ) : ( SimpleDateFormat ) simpleDateFormat2 . clone ( ) ;
TimeZone f = l . f ( ) ;
if ( f = = null | | f . equals ( simpleDateFormat3 . getTimeZone ( ) ) ) {
z2 = false ;
}
if ( z2 ) {
simpleDateFormat3 . setTimeZone ( f ) ;
}
return r ( Boolean . FALSE , simpleDateFormat3 ) ;
}
2021-12-17 22:01:24 +00:00
@Override // b.g.a.c.n
2021-08-09 22:50:52 +00:00
public boolean d ( x xVar , T t ) {
return false ;
}
public boolean p ( x xVar ) {
Boolean bool = this . _useTimestamp ;
if ( bool ! = null ) {
return bool . booleanValue ( ) ;
}
if ( this . _customFormat ! = null ) {
return false ;
}
if ( xVar ! = null ) {
return xVar . D ( w . WRITE_DATES_AS_TIMESTAMPS ) ;
}
2021-12-17 22:01:24 +00:00
StringBuilder R = b . d . b . a . a . R ( " Null SerializerProvider passed for " ) ;
2021-11-05 21:05:33 +00:00
R . append ( this . _handledType . getName ( ) ) ;
throw new IllegalArgumentException ( R . toString ( ) ) ;
2021-08-09 22:50:52 +00:00
}
2021-12-17 22:01:24 +00:00
public void q ( Date date , b . g . a . b . d dVar , x xVar ) throws IOException {
2021-08-09 22:50:52 +00:00
if ( this . _customFormat = = null ) {
Objects . requireNonNull ( xVar ) ;
if ( xVar . D ( w . WRITE_DATES_AS_TIMESTAMPS ) ) {
dVar . I ( date . getTime ( ) ) ;
} else {
2021-11-05 21:05:33 +00:00
dVar . j0 ( xVar . j ( ) . format ( date ) ) ;
2021-08-09 22:50:52 +00:00
}
} else {
DateFormat andSet = this . _reusedCustomFormat . getAndSet ( null ) ;
if ( andSet = = null ) {
andSet = ( DateFormat ) this . _customFormat . clone ( ) ;
}
2021-11-05 21:05:33 +00:00
dVar . j0 ( andSet . format ( date ) ) ;
2021-08-09 22:50:52 +00:00
this . _reusedCustomFormat . compareAndSet ( null , andSet ) ;
}
}
public abstract l < T > r ( Boolean bool , DateFormat dateFormat ) ;
}