Skip to content

Commit

Permalink
Fixes the issue where the toString of OffsetDateTime truncates traili…
Browse files Browse the repository at this point in the history
…ng Zeros
  • Loading branch information
rcunn87 committed Apr 21, 2022
1 parent 3e47fb4 commit 3fa3471
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/sforce/ws/bind/TypeMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.math.BigDecimal;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalQueries;
import java.util.*;
Expand All @@ -66,6 +67,8 @@ public class TypeMapper {
private static final HashSet<String> keywords = getKeyWords();
private static HashMap<String, Class<?>> primitiveClassCache = getPrimitiveClassCache();

private static final DateTimeFormatter DTF = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX");

// True if interfaces are generated for the WSDL
private boolean generateInterfaces;
private boolean generateExtendedErrorCodes;
Expand Down Expand Up @@ -421,7 +424,7 @@ private void writeSingleObject(XmlOutputStream out, TypeInfo info, Object value)
String s = calendarCodec.getValueAsString(value);
writeSimpleType(out, info, s, true, Calendar.class.getName());
} else if (value instanceof OffsetDateTime) {
writeSimpleType(out, info, value.toString(), true, OffsetDateTime.class.getName());
writeSimpleType(out, info, DTF.format((OffsetDateTime)value), true, OffsetDateTime.class.getName());
} else if (value instanceof OffsetDate) {
writeSimpleType(out, info, value.toString(), true, OffsetDate.class.getName());
} else if (value instanceof OffsetTime) {
Expand All @@ -445,7 +448,6 @@ private void writeSingleObject(XmlOutputStream out, TypeInfo info, Object value)
writeString(out, info, value.toString(), true);
}
}

private void writeNull(XmlOutputStream out, TypeInfo info) throws IOException {
out.writeStartTag(getNamespace(info), info.getName());
out.writeAttribute(Constants.SCHEMA_INSTANCE_NS, "nil", "true");
Expand Down

0 comments on commit 3fa3471

Please sign in to comment.