Skip to content

Commit 93ad891

Browse files
committed
Fix date/time parsing
1 parent d106b4e commit 93ad891

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/com/amadeus/resources/Resource.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.amadeus.Amadeus;
44
import com.amadeus.Response;
55
import com.google.gson.Gson;
6+
import com.google.gson.GsonBuilder;
67
import lombok.Getter;
78

89
/**
@@ -27,7 +28,8 @@ protected Resource() {}
2728
* @hide as only used internally
2829
*/
2930
public static Resource[] fromArray(Response response, Class klass) {
30-
Resource[] resources = (Resource[]) new Gson().fromJson(response.getData(), klass);
31+
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
32+
Resource[] resources = (Resource[]) gson.fromJson(response.getData(), klass);
3133
for (Resource resource : resources) {
3234
resource.response = response;
3335
resource.deSerializationClass = klass;
@@ -41,8 +43,10 @@ public static Resource[] fromArray(Response response, Class klass) {
4143
* @hide as only used internally
4244
*/
4345
public static Resource fromObject(Response response, Class klass) {
44-
Resource resource = (Resource) new Gson().fromJson(response.getData(), klass);
46+
Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
47+
Resource resource = (Resource) gson.fromJson(response.getData(), klass);
4548
resource.response = response;
49+
resource.deSerializationClass = klass;
4650
return resource;
4751
}
4852
}

src/main/java/com/amadeus/shopping/FlightDates.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.amadeus.exceptions.ResponseException;
77
import com.amadeus.resources.FlightDate;
88
import com.amadeus.resources.Resource;
9-
import com.google.gson.Gson;
109

1110
/**
1211
* <p>

0 commit comments

Comments
 (0)