| 58 | }; |
| 59 | |
| 60 | @Override |
| 61 | public String toString(Object o, String formatString, Locale locale) { |
| 62 | Date d; |
| 63 | if ( formatString==null ) formatString = "short"; |
| 64 | if ( o instanceof Calendar ) d = ((Calendar)o).getTime(); |
| 65 | else d = (Date)o; |
| 66 | Integer styleI = formatToInt.get(formatString); |
| 67 | DateFormat f; |
| 68 | if ( styleI==null ) f = new SimpleDateFormat(formatString, locale); |
| 69 | else { |
| 70 | int style = styleI.intValue(); |
| 71 | if ( formatString.startsWith("date:") ) f = DateFormat.getDateInstance(style, locale); |
| 72 | else if ( formatString.startsWith("time:") ) f = DateFormat.getTimeInstance(style, locale); |
| 73 | else f = DateFormat.getDateTimeInstance(style, style, locale); |
| 74 | } |
| 75 | return f.format(d); |
| 76 | } |
| 77 | } |