1919
2020import java .util .Map ;
2121import java .net .URI ;
22- import java .time .Instant ;
2322import java .time .OffsetDateTime ;
24- import java .time .ZoneOffset ;
2523
26- import io .cloudevents .CloudEvent ;
2724import io .cloudevents .CloudEventData ;
2825import io .cloudevents .SpecVersion ;
2926import io .cloudevents .AvroCloudEvent ;
30- import io .cloudevents .AvroCloudEventData ;
31- import io .cloudevents .core .builder .CloudEventBuilder ;
27+ import io .cloudevents .core .data .BytesCloudEventData ;
3228import io .cloudevents .core .v1 .CloudEventV1 ;
3329import io .cloudevents .rw .CloudEventRWException ;
3430import io .cloudevents .rw .CloudEventReader ;
@@ -57,9 +53,7 @@ public <W extends CloudEventWriter<R>, R> R read(CloudEventWriterFactory<W, R> w
5753
5854 if (key .equals (CloudEventV1 .TIME )) {
5955 // OffsetDateTime
60- Long timeAsLong = (Long ) entry .getValue ();
61- Instant timeAsInstant = Instant .ofEpochMilli (timeAsLong );
62- OffsetDateTime value = OffsetDateTime .ofInstant (timeAsInstant , ZoneOffset .UTC );
56+ OffsetDateTime value = OffsetDateTime .parse ((String ) entry .getValue ());
6357 writer .withContextAttribute (key , value );
6458
6559 } else if (key .equals (CloudEventV1 .DATASCHEMA )) {
@@ -72,8 +66,13 @@ public <W extends CloudEventWriter<R>, R> R read(CloudEventWriterFactory<W, R> w
7266 }
7367 }
7468
75- // TOOD: data
76- return writer .end ();
69+ byte [] data = (byte []) this .avroCloudEvent .getData ();
70+
71+ if (data != null ) {
72+ return writer .end (mapper .map (BytesCloudEventData .wrap (data )));
73+ } else {
74+ return writer .end ();
75+ }
7776 }
7877
7978}
0 commit comments