}
// should this be made accessible in the component?
Locale loc = null;
String format = (String) component.getAttributes().getValue("format");
LocalizationService lclService = Aura.getLocalizationService();
if (format == null) {
String dateStyle = (String) component.getAttributes().getValue("dateStyle");
String timeStyle = (String) component.getAttributes().getValue("timeStyle");
DateService dateService = DateServiceImpl.get();
int intDateStyle = dateService.getStyle(dateStyle);
int intTimeStyle = dateService.getStyle(timeStyle);
return lclService.formatDateTime(cal.getTime(), loc, tz, intDateStyle, intTimeStyle);
} else {
// no pattern, no result
if (AuraTextUtil.isEmptyOrWhitespace(format)) {
return "";
} else {
try {
return lclService.formatDateTime(cal.getTime(), loc, tz, format);
} catch (IllegalArgumentException e) {
return "You must provide a valid format: " + e.getMessage();
}
}