Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String format(Date date, Locale locale, FORMAT_TYPE type) {
- log.debug("Formatting date: " + date + " with locale " + locale);
- DateFormat dateFormat = null;
- if (type == FORMAT_TYPE.TIMESTAMP) {
- String formatValue = Context.getAdministrationService().getGlobalPropertyValue(OpenmrsConstants.GLOBAL_PROPERTY_DATEANDTIME_DISPLAY_FORMAT, null);
- if (StringUtils.isEmpty(formatValue))
- dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
- else
- dateFormat = new OpenmrsDateFormat(new SimpleDateFormat(formatValue), locale);
- }
- else if (type == FORMAT_TYPE.TIME) {
- dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);
- }
- else {
- //if (type == FORMAT_TYPE.DATE) (default)
- dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
- }
- return date == null ? "" : dateFormat.format(date);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement