|
16 | 16 |
|
17 | 17 | package com.google.gcloud.compute; |
18 | 18 |
|
19 | | -import com.google.api.client.util.DateTime; |
20 | 19 | import com.google.api.services.compute.model.Zone.MaintenanceWindows; |
21 | 20 | import com.google.common.base.Function; |
22 | 21 | import com.google.common.base.MoreObjects; |
23 | 22 | import com.google.common.collect.Lists; |
24 | 23 |
|
| 24 | +import org.joda.time.format.DateTimeFormatter; |
| 25 | +import org.joda.time.format.ISODateTimeFormat; |
| 26 | + |
25 | 27 | import java.io.Serializable; |
26 | 28 | import java.math.BigInteger; |
27 | 29 | import java.util.List; |
@@ -50,6 +52,7 @@ public com.google.api.services.compute.model.Zone apply(Zone region) { |
50 | 52 | }; |
51 | 53 |
|
52 | 54 | private static final long serialVersionUID = 6113636504417213010L; |
| 55 | + private static final DateTimeFormatter TIMESTAMP_FORMATTER = ISODateTimeFormat.dateTime(); |
53 | 56 |
|
54 | 57 | private final ZoneId zoneId; |
55 | 58 | private final String id; |
@@ -162,16 +165,16 @@ MaintenanceWindows toPb() { |
162 | 165 | return new MaintenanceWindows() |
163 | 166 | .setName(name) |
164 | 167 | .setDescription(description) |
165 | | - .setBeginTime(beginTime != null ? new DateTime(beginTime).toStringRfc3339() : null) |
166 | | - .setEndTime(endTime != null ? new DateTime(endTime).toStringRfc3339() : null); |
| 168 | + .setBeginTime(beginTime != null ? TIMESTAMP_FORMATTER.print(beginTime) : null) |
| 169 | + .setEndTime(endTime != null ? TIMESTAMP_FORMATTER.print(endTime) : null); |
167 | 170 | } |
168 | 171 |
|
169 | 172 | static MaintenanceWindow fromPb(MaintenanceWindows windowPb) { |
170 | 173 | return new MaintenanceWindow(windowPb.getName(), windowPb.getDescription(), |
171 | 174 | windowPb.getBeginTime() != null |
172 | | - ? DateTime.parseRfc3339(windowPb.getBeginTime()).getValue() : null, |
| 175 | + ? TIMESTAMP_FORMATTER.parseMillis(windowPb.getBeginTime()) : null, |
173 | 176 | windowPb.getEndTime() != null |
174 | | - ? DateTime.parseRfc3339(windowPb.getEndTime()).getValue() : null); |
| 177 | + ? TIMESTAMP_FORMATTER.parseMillis(windowPb.getEndTime()) : null); |
175 | 178 | } |
176 | 179 | } |
177 | 180 |
|
@@ -338,7 +341,7 @@ com.google.api.services.compute.model.Zone toPb() { |
338 | 341 | zonePb.setId(new BigInteger(id)); |
339 | 342 | } |
340 | 343 | if (creationTimestamp != null) { |
341 | | - zonePb.setCreationTimestamp(new DateTime(creationTimestamp).toStringRfc3339()); |
| 344 | + zonePb.setCreationTimestamp(TIMESTAMP_FORMATTER.print(creationTimestamp)); |
342 | 345 | } |
343 | 346 | zonePb.setName(zoneId.zone()); |
344 | 347 | zonePb.setDescription(description); |
@@ -370,7 +373,7 @@ static Zone fromPb(com.google.api.services.compute.model.Zone zonePb) { |
370 | 373 | builder.id(zonePb.getId().toString()); |
371 | 374 | } |
372 | 375 | if (zonePb.getCreationTimestamp() != null) { |
373 | | - builder.creationTimestamp(DateTime.parseRfc3339(zonePb.getCreationTimestamp()).getValue()); |
| 376 | + builder.creationTimestamp(TIMESTAMP_FORMATTER.parseMillis(zonePb.getCreationTimestamp())); |
374 | 377 | } |
375 | 378 | builder.description(zonePb.getDescription()); |
376 | 379 | if (zonePb.getStatus() != null) { |
|
0 commit comments