Trim out hours from date picker export on xml and json(ref #7185)
This commit is contained in:
parent
4da99d6d83
commit
4eb15da95a
|
@ -20,6 +20,9 @@ import java.io.BufferedWriter;
|
|||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
@ -126,9 +129,13 @@ public class ExportXmlBuilder {
|
|||
Map<String, Object> jsonElement = mapper.readValue(field.getValue().toString(), Map.class);
|
||||
valueField.setTextContent((jsonElement.get("label") != null ? jsonElement.get("label").toString() : jsonElement.get("name") != null ? jsonElement.get("name").toString() : ""));
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
valueField.setTextContent(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(Instant.parse(field.getValue().toString())));
|
||||
} catch (Exception exc) {
|
||||
valueField.setTextContent(field.getValue().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
elementField.appendChild(valueField);
|
||||
}
|
||||
elementFields.appendChild(elementField);
|
||||
|
|
|
@ -20,6 +20,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -152,8 +156,13 @@ public class DatasetRDAMapper {
|
|||
templateIdsToValues.entrySet().forEach(entry -> {
|
||||
boolean isFound = foundNodes.stream().anyMatch(node -> node.get("id").asText().equals(entry.getKey()));
|
||||
if (!isFound && entry.getValue() != null && !entry.getValue().toString().isEmpty()) {
|
||||
try {
|
||||
Instant time = Instant.parse(entry.getValue().toString());
|
||||
rda.setAdditionalProperty(entry.getKey(), DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(time));
|
||||
} catch (DateTimeParseException e) {
|
||||
rda.setAdditionalProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue