Advertisement
Guest User

Untitled

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