What is the best way to convert XMLGregorianCalendar objects to \'MM/dd/yyyy hh:mm\' String?
Please check this static utility. You just mentioned a pattern like "ddMMyy" or "HHmm" or what ever you want.. this will work wonderfully.
public static String getDateTime(XMLGregorianCalendar gDate, String pattern){
return Optional.ofNullable(gDate)
.map(gdate -> {
Calendar calendar = gDate.toGregorianCalendar();
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
formatter.setTimeZone(calendar.getTimeZone());
return formatter.format(calendar.getTime());
})
.orElse(null);
}