Advertisement
Guest User

Untitled

a guest
Jan 16th, 2013
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public static String format(Date date, Locale locale, FORMAT_TYPE type) {
  2. log.debug("Formatting date: " + date + " with locale " + locale);
  3.  
  4. DateFormat dateFormat = null;
  5.  
  6. if (type == FORMAT_TYPE.TIMESTAMP) {
  7. String formatValue = Context.getAdministrationService().getGlobalPropertyValue(OpenmrsConstants.GLOBAL_PROPERTY_DATEANDTIME_DISPLAY_FORMAT, null);
  8. if (StringUtils.isEmpty(formatValue))
  9. dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
  10. else
  11. dateFormat = new OpenmrsDateFormat(new SimpleDateFormat(formatValue), locale);
  12. }
  13. else if (type == FORMAT_TYPE.TIME) {
  14. dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);
  15. }
  16. else {
  17. //if (type == FORMAT_TYPE.DATE) (default)
  18. dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
  19. }
  20. return date == null ? "" : dateFormat.format(date);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement