This repository was archived by the owner on Jul 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/java/org/energyos/espi/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package org .energyos .espi .common .models .atom .adapters ;
1818
19+ import java .text .SimpleDateFormat ;
20+
1921import org .energyos .espi .common .models .atom .DateTimeType ;
2022import org .joda .time .DateTime ;
2123import org .joda .time .DateTimeZone ;
@@ -32,6 +34,9 @@ public DateTime unmarshal(JAXBElement<DateTimeType> v) throws Exception {
3234
3335 @ Override
3436 public JAXBElement <DateTimeType > marshal (DateTime v ) throws Exception {
37+ SimpleDateFormat fmt = new SimpleDateFormat ( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
38+
39+ String dateFormatted = fmt .format (v .toDate ());
3540 return null ;
3641 }
3742}
Original file line number Diff line number Diff line change 11
22package org .energyos .espi .common .utils ;
33
4+ import java .text .SimpleDateFormat ;
5+ import java .util .GregorianCalendar ;
46import java .util .List ;
7+ import java .util .TimeZone ;
58
69import javax .xml .bind .Marshaller ;
10+ import javax .xml .datatype .XMLGregorianCalendar ;
711
812import org .energyos .espi .common .models .atom .ContentType ;
13+ import org .energyos .espi .common .models .atom .DateTimeType ;
914import org .energyos .espi .common .models .atom .EntryType ;
1015import org .energyos .espi .common .models .atom .LinkType ;
1116
@@ -46,6 +51,14 @@ public void beforeMarshal(Object source) {
4651 ((LinkType ) source ).setHref (relRefList .remove (0 ));
4752 }
4853 }
54+
55+ if ((source instanceof DateTimeType )) {
56+ // Normalize the calendar so it will print the "Z" correctly
57+ XMLGregorianCalendar xmlCal = ((DateTimeType )source ).getValue ();
58+ XMLGregorianCalendar xmlCal1 = xmlCal .normalize ();
59+ ((DateTimeType )source ).setValue (xmlCal1 );
60+ }
61+
4962 }
5063
5164 @ Override
You can’t perform that action at this time.
0 commit comments