| | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | private final String pattern;
|
| | |
|
| | | |
| | | public DateCellRenderer(String pattern, Color foreground) {
|
| | | this.pattern = (pattern == null ? "yyyy-MM-dd HH:mm" : pattern);
|
| | | setForeground(foreground);
|
| | |
| | | super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
| | | if (value instanceof Date) {
|
| | | Date date = (Date) value;
|
| | | String timeAgo;
|
| | | String strDate;
|
| | | String title;
|
| | | String dateString;
|
| | | if (date.getTime() == 0) {
|
| | | timeAgo = "--";
|
| | | strDate = "never";
|
| | | title = "--";
|
| | | dateString = "never";
|
| | | } else {
|
| | | timeAgo = TimeUtils.timeAgo(date);
|
| | | strDate = new SimpleDateFormat(pattern).format((Date) value);
|
| | | title = Translation.getTimeUtils().timeAgo(date);
|
| | | dateString = new SimpleDateFormat(pattern).format((Date) value);
|
| | | }
|
| | |
|
| | | this.setText(timeAgo);
|
| | | this.setToolTipText(strDate);
|
| | | if ((System.currentTimeMillis() - date.getTime()) > 10 * 24 * 60 * 60 * 1000L) {
|
| | | String tmp = dateString;
|
| | | dateString = title;
|
| | | title = tmp;
|
| | | }
|
| | | this.setText(title);
|
| | | this.setToolTipText(dateString);
|
| | | }
|
| | | return this;
|
| | | }
|