Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exception when a date field is empty #261

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ already.
<dependency>
<groupId>com.mercadopago</groupId>
<artifactId>sdk-java</artifactId>
<version>2.1.12</version>
<version>2.1.13</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.mercadopago</groupId>
<artifactId>sdk-java</artifactId>
<version>2.1.12</version>
<version>2.1.13</version>
<packaging>jar</packaging>

<name>Mercadopago SDK</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mercadopago/MercadoPagoConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/** Mercado Pago configuration class. */
public class MercadoPagoConfig {

public static final String CURRENT_VERSION = "2.1.12";
public static final String CURRENT_VERSION = "2.1.13";

public static final String PRODUCT_ID = "BC32A7VTRPP001U8NHJ0";

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/mercadopago/serialization/Serializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public class Serializer {
private static final String SERIALIZE_DATE_FORMAT_ISO8601 = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX";

private static OffsetDateTime parseDateTime(JsonElement json) {
if (json == null || json.getAsString().isEmpty()) {
return null;
}

for (int i = 0; i < ISO8601_DATETIME_FORMATTERS.length; i++) {
try {
return OffsetDateTime.parse(json.getAsString(), ISO8601_DATETIME_FORMATTERS[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ private void assertPaymentFields(Payment payment) {
assertEquals(date, payment.getDateApproved());
assertEquals(date, payment.getDateLastUpdated());
assertNull(payment.getDateOfExpiration());
assertEquals(date, payment.getMoneyReleaseDate());
assertNull(payment.getMoneyReleaseDate());
assertEquals("regular_payment", payment.getOperationType());
assertEquals("24", payment.getIssuerId());
assertEquals("master", payment.getPaymentMethodId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"date_approved": "2022-01-10T10:10:10.000-00:00",
"date_last_updated": "2022-01-10T10:10:10.000-00:00",
"date_of_expiration": null,
"money_release_date": "2022-01-10T10:10:10.000-00:00",
"money_release_date": "",
"operation_type": "regular_payment",
"issuer_id": "24",
"payment_method_id": "master",
Expand Down
Loading