Purpose
This exit allows UC to override the user’s preferred date format and to render whatever date format is necessary.
Applies To
Add Issue screen
Signature
public String ucFormatLogAreaTimestamp( String dateInUsersFormat,
Calendar theTimestamp,
SesameSession session,
Connection dbconn) {
return null; // this means "respect the user's preferences in date formatting"
}
Notes
While it may seem trivial to format the date, this method is responsible for ensuring that it is sensitive to the user’s locale, which may dictate date formats with different ordering for the fields, without which sensitivity there will likely be serious misunderstandings. It should be understood that any formatting done here that is in conflict with the user’s preferred format will be inconsistent with all other dates seen by the user. ExtraView therefore disavows any responsibility for the misunderstandings and inconsistencies and any damage incurred therefrom due to the insertion of customer logic in this method.
Example
public String ucFormatLogAreaTimestamp (String dateInUsersFormat,
Calendar theTimestamp,
SesameSession session,
Connection dbconn) {
String strDate = this.getStringFromCalendar(
theTimestamp,"MMM dd, yyyy HH:mm:ss");
StringBuffer dateFormat = new StringBuffer();
dateFormat.append("");
dateFormat.append(strDate);
dateFormat.append("");
return strDate;
}
/**
* Calendar --> String converter
*/
protected static String getStringFromCalendar (
java.util.Calendar cal, String format) {
if (cal == null) return null;
Timestamp ts = null;
String s = null;
try {
ts = Convert.toDate(cal);
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
s = sdf.format(ts);
}
catch (NullPointerException e) {
ErrorWriter.write(e, ErrorWriter.LOG);
s = null;
}
return s;
}