Add support for the exported date format on wordBuilder

This commit is contained in:
George Kalampokis 2021-11-24 16:41:01 +02:00
parent fc71e95cf3
commit 8524bce2e0
1 changed files with 12 additions and 2 deletions

View File

@ -25,9 +25,12 @@ import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -352,8 +355,15 @@ public class WordBuilder {
if (field.getValue() == null || field.getValue().equals("false")) return null; if (field.getValue() == null || field.getValue().equals("false")) return null;
return data.getLabel(); return data.getLabel();
case "datepicker": case "datepicker":
case "datePicker": case "datePicker":{
return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(Instant.parse((String)field.getValue())) : ""; Instant instant;
try {
instant = Instant.parse((String) field.getValue());
} catch (DateTimeParseException ex) {
instant = (Instant) DateTimeFormatter.ofPattern("yyyy-MM-dd").parse((String)field.getValue());
}
return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : "";
}
case "freetext": case "freetext":
case "textarea": case "textarea":
case "richTextarea": case "richTextarea":