Showing
1 changed file
with
8 additions
and
6 deletions
| ... | @@ -439,8 +439,6 @@ public class swiftApi { | ... | @@ -439,8 +439,6 @@ public class swiftApi { |
| 439 | 439 | ||
| 440 | 440 | ||
| 441 | let expirationString = dictionary["expiration"] as? String? ?? "" | 441 | let expirationString = dictionary["expiration"] as? String? ?? "" |
| 442 | - let createdString = dictionary["created"] as? String? ?? "" | ||
| 443 | - | ||
| 444 | // Example expirationString: Optional(2022-12-05 01:55) | 442 | // Example expirationString: Optional(2022-12-05 01:55) |
| 445 | 443 | ||
| 446 | let dateFormatter = DateFormatter() | 444 | let dateFormatter = DateFormatter() |
| ... | @@ -453,15 +451,19 @@ public class swiftApi { | ... | @@ -453,15 +451,19 @@ public class swiftApi { |
| 453 | self.expiration = "" | 451 | self.expiration = "" |
| 454 | } | 452 | } |
| 455 | 453 | ||
| 456 | - if let date = dateFormatter.date(from: createdString ?? "") { | 454 | + let createdString = dictionary["created"] as? String? ?? "" |
| 457 | - dateFormatter.dateFormat = "dd/MM/yyyy" | 455 | +// Example createdString: Optional("2022-08-26 15:20:22.287097") |
| 458 | - let resultString = dateFormatter.string(from: date) | 456 | + |
| 457 | + let dateFormatter2 = DateFormatter() | ||
| 458 | + dateFormatter2.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSSSS" | ||
| 459 | + if let date = dateFormatter2.date(from: createdString ?? "") { | ||
| 460 | + dateFormatter2.dateFormat = "dd/MM/yyyy" | ||
| 461 | + let resultString = dateFormatter2.string(from: date) | ||
| 459 | self.created = resultString | 462 | self.created = resultString |
| 460 | } else { | 463 | } else { |
| 461 | self.created = "" | 464 | self.created = "" |
| 462 | } | 465 | } |
| 463 | 466 | ||
| 464 | - | ||
| 465 | } | 467 | } |
| 466 | 468 | ||
| 467 | 469 | ... | ... |
-
Please register or login to post a comment