HttpDate.smali 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. .class public final Lokhttp3/internal/http/HttpDate;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # static fields
  5. .field private static final BROWSER_COMPATIBLE_DATE_FORMATS:[Ljava/text/DateFormat;
  6. .field private static final BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS:[Ljava/lang/String;
  7. .field public static final MAX_DATE:J = 0xe677d21fdbffL
  8. .field private static final STANDARD_DATE_FORMAT:Ljava/lang/ThreadLocal;
  9. .annotation system Ldalvik/annotation/Signature;
  10. value = {
  11. "Ljava/lang/ThreadLocal<",
  12. "Ljava/text/DateFormat;",
  13. ">;"
  14. }
  15. .end annotation
  16. .end field
  17. # direct methods
  18. .method static constructor <clinit>()V
  19. .locals 3
  20. new-instance v0, Lokhttp3/internal/http/HttpDate$1;
  21. invoke-direct {v0}, Lokhttp3/internal/http/HttpDate$1;-><init>()V
  22. sput-object v0, Lokhttp3/internal/http/HttpDate;->STANDARD_DATE_FORMAT:Ljava/lang/ThreadLocal;
  23. const/16 v0, 0xf
  24. new-array v0, v0, [Ljava/lang/String;
  25. const/4 v1, 0x0
  26. const-string v2, "EEE, dd MMM yyyy HH:mm:ss zzz"
  27. aput-object v2, v0, v1
  28. const/4 v1, 0x1
  29. const-string v2, "EEEE, dd-MMM-yy HH:mm:ss zzz"
  30. aput-object v2, v0, v1
  31. const/4 v1, 0x2
  32. const-string v2, "EEE MMM d HH:mm:ss yyyy"
  33. aput-object v2, v0, v1
  34. const/4 v1, 0x3
  35. const-string v2, "EEE, dd-MMM-yyyy HH:mm:ss z"
  36. aput-object v2, v0, v1
  37. const/4 v1, 0x4
  38. const-string v2, "EEE, dd-MMM-yyyy HH-mm-ss z"
  39. aput-object v2, v0, v1
  40. const/4 v1, 0x5
  41. const-string v2, "EEE, dd MMM yy HH:mm:ss z"
  42. aput-object v2, v0, v1
  43. const/4 v1, 0x6
  44. const-string v2, "EEE dd-MMM-yyyy HH:mm:ss z"
  45. aput-object v2, v0, v1
  46. const/4 v1, 0x7
  47. const-string v2, "EEE dd MMM yyyy HH:mm:ss z"
  48. aput-object v2, v0, v1
  49. const/16 v1, 0x8
  50. const-string v2, "EEE dd-MMM-yyyy HH-mm-ss z"
  51. aput-object v2, v0, v1
  52. const/16 v1, 0x9
  53. const-string v2, "EEE dd-MMM-yy HH:mm:ss z"
  54. aput-object v2, v0, v1
  55. const/16 v1, 0xa
  56. const-string v2, "EEE dd MMM yy HH:mm:ss z"
  57. aput-object v2, v0, v1
  58. const/16 v1, 0xb
  59. const-string v2, "EEE,dd-MMM-yy HH:mm:ss z"
  60. aput-object v2, v0, v1
  61. const/16 v1, 0xc
  62. const-string v2, "EEE,dd-MMM-yyyy HH:mm:ss z"
  63. aput-object v2, v0, v1
  64. const/16 v1, 0xd
  65. const-string v2, "EEE, dd-MM-yyyy HH:mm:ss z"
  66. aput-object v2, v0, v1
  67. const/16 v1, 0xe
  68. const-string v2, "EEE MMM d yyyy HH:mm:ss z"
  69. aput-object v2, v0, v1
  70. sput-object v0, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS:[Ljava/lang/String;
  71. sget-object v0, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS:[Ljava/lang/String;
  72. array-length v0, v0
  73. new-array v0, v0, [Ljava/text/DateFormat;
  74. sput-object v0, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMATS:[Ljava/text/DateFormat;
  75. return-void
  76. .end method
  77. .method private constructor <init>()V
  78. .locals 0
  79. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  80. return-void
  81. .end method
  82. .method public static format(Ljava/util/Date;)Ljava/lang/String;
  83. .locals 1
  84. sget-object v0, Lokhttp3/internal/http/HttpDate;->STANDARD_DATE_FORMAT:Ljava/lang/ThreadLocal;
  85. invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;
  86. move-result-object v0
  87. check-cast v0, Ljava/text/DateFormat;
  88. invoke-virtual {v0, p0}, Ljava/text/DateFormat;->format(Ljava/util/Date;)Ljava/lang/String;
  89. move-result-object p0
  90. return-object p0
  91. .end method
  92. .method public static parse(Ljava/lang/String;)Ljava/util/Date;
  93. .locals 9
  94. invoke-virtual {p0}, Ljava/lang/String;->length()I
  95. move-result v0
  96. const/4 v1, 0x0
  97. if-nez v0, :cond_0
  98. return-object v1
  99. :cond_0
  100. new-instance v0, Ljava/text/ParsePosition;
  101. const/4 v2, 0x0
  102. invoke-direct {v0, v2}, Ljava/text/ParsePosition;-><init>(I)V
  103. sget-object v3, Lokhttp3/internal/http/HttpDate;->STANDARD_DATE_FORMAT:Ljava/lang/ThreadLocal;
  104. invoke-virtual {v3}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;
  105. move-result-object v3
  106. check-cast v3, Ljava/text/DateFormat;
  107. invoke-virtual {v3, p0, v0}, Ljava/text/DateFormat;->parse(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/util/Date;
  108. move-result-object v3
  109. invoke-virtual {v0}, Ljava/text/ParsePosition;->getIndex()I
  110. move-result v4
  111. invoke-virtual {p0}, Ljava/lang/String;->length()I
  112. move-result v5
  113. if-ne v4, v5, :cond_1
  114. return-object v3
  115. :cond_1
  116. sget-object v3, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS:[Ljava/lang/String;
  117. monitor-enter v3
  118. :try_start_0
  119. sget-object v4, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS:[Ljava/lang/String;
  120. array-length v4, v4
  121. const/4 v5, 0x0
  122. :goto_0
  123. if-ge v5, v4, :cond_4
  124. sget-object v6, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMATS:[Ljava/text/DateFormat;
  125. aget-object v6, v6, v5
  126. if-nez v6, :cond_2
  127. new-instance v6, Ljava/text/SimpleDateFormat;
  128. sget-object v7, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMAT_STRINGS:[Ljava/lang/String;
  129. aget-object v7, v7, v5
  130. sget-object v8, Ljava/util/Locale;->US:Ljava/util/Locale;
  131. invoke-direct {v6, v7, v8}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;Ljava/util/Locale;)V
  132. sget-object v7, Lokhttp3/internal/Util;->UTC:Ljava/util/TimeZone;
  133. invoke-virtual {v6, v7}, Ljava/text/DateFormat;->setTimeZone(Ljava/util/TimeZone;)V
  134. sget-object v7, Lokhttp3/internal/http/HttpDate;->BROWSER_COMPATIBLE_DATE_FORMATS:[Ljava/text/DateFormat;
  135. aput-object v6, v7, v5
  136. :cond_2
  137. invoke-virtual {v0, v2}, Ljava/text/ParsePosition;->setIndex(I)V
  138. invoke-virtual {v6, p0, v0}, Ljava/text/DateFormat;->parse(Ljava/lang/String;Ljava/text/ParsePosition;)Ljava/util/Date;
  139. move-result-object v6
  140. invoke-virtual {v0}, Ljava/text/ParsePosition;->getIndex()I
  141. move-result v7
  142. if-eqz v7, :cond_3
  143. monitor-exit v3
  144. return-object v6
  145. :cond_3
  146. add-int/lit8 v5, v5, 0x1
  147. goto :goto_0
  148. :cond_4
  149. monitor-exit v3
  150. return-object v1
  151. :catchall_0
  152. move-exception p0
  153. monitor-exit v3
  154. :try_end_0
  155. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  156. goto :goto_2
  157. :goto_1
  158. throw p0
  159. :goto_2
  160. goto :goto_1
  161. .end method