2020import com .google .gson .stream .JsonToken ;
2121import com .google .gson .stream .JsonWriter ;
2222import java .io .IOException ;
23- import org .joda .time .DateTime ;
24- import org .joda .time .DateTimeZone ;
23+ import java .time .Instant ;
24+ import java .time .LocalDateTime ;
25+ import java .time .ZoneId ;
2526
2627/**
27- * This class handles conversion from JSON to {@link DateTime }s.
28+ * This class handles conversion from JSON to {@link LocalDateTime }s.
2829 *
2930 * <p>Please see <a
3031 * href="https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/TypeAdapter.html">TypeAdapter</a>
3132 * for more detail.
3233 */
33- public class DateTimeAdapter extends TypeAdapter <DateTime > {
34+ public class DateTimeAdapter extends TypeAdapter <LocalDateTime > {
3435
3536 /**
36- * Read a Time object from a Directions API result and convert it to a {@link DateTime }.
37+ * Read a Time object from a Directions API result and convert it to a {@link LocalDateTime }.
3738 *
3839 * <p>We are expecting to receive something akin to the following:
3940 *
@@ -46,7 +47,7 @@ public class DateTimeAdapter extends TypeAdapter<DateTime> {
4647 * </pre>
4748 */
4849 @ Override
49- public DateTime read (JsonReader reader ) throws IOException {
50+ public LocalDateTime read (JsonReader reader ) throws IOException {
5051 if (reader .peek () == JsonToken .NULL ) {
5152 reader .nextNull ();
5253 return null ;
@@ -69,12 +70,12 @@ public DateTime read(JsonReader reader) throws IOException {
6970 }
7071 reader .endObject ();
7172
72- return new DateTime ( secondsSinceEpoch * 1000 , DateTimeZone . forID (timeZoneId ));
73+ return LocalDateTime . ofInstant ( Instant . ofEpochMilli ( secondsSinceEpoch * 1000 ), ZoneId . of (timeZoneId ));
7374 }
7475
7576 /** This method is not implemented. */
7677 @ Override
77- public void write (JsonWriter writer , DateTime value ) throws IOException {
78+ public void write (JsonWriter writer , LocalDateTime value ) throws IOException {
7879 throw new UnsupportedOperationException ("Unimplemented method" );
7980 }
8081}
0 commit comments