19 package org.sleuthkit.autopsy.contentviewers;
21 import java.awt.Component;
23 import java.lang.reflect.InvocationTargetException;
24 import java.text.SimpleDateFormat;
25 import java.util.Date;
26 import java.util.logging.Level;
27 import javax.swing.JTable;
28 import javax.swing.table.DefaultTableCellRenderer;
29 import org.openide.nodes.Node;
36 class EpochTimeCellRenderer
extends DefaultTableCellRenderer {
38 private static final long serialVersionUID = 1L;
41 private static final String FORMAT_STRING =
"yyyy/MM/dd HH:mm:ss";
42 private static final SimpleDateFormat DATE_FORMAT =
new SimpleDateFormat(FORMAT_STRING);
44 private final boolean renderAsEpoch;
46 EpochTimeCellRenderer(
boolean renderAsEpoch) {
47 this.renderAsEpoch = renderAsEpoch;
51 public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
55 super.setForeground(table.getSelectionForeground());
56 super.setBackground(table.getSelectionBackground());
58 super.setForeground( table.getForeground());
59 super.setBackground( table.getBackground());
69 if (value instanceof Node.Property<?>) {
70 Node.Property<?> nodeProp = (Node.Property)value;
71 textStr = nodeProp.getValue().toString();
75 long epochTime = Long.parseUnsignedLong(textStr);
77 Font font = getFont();
78 setFont(font.deriveFont(font.getStyle() | Font.ITALIC));
79 setText(DATE_FORMAT.format(
new Date(epochTime)));
89 catch (NumberFormatException e) {
91 LOGGER.log(Level.INFO,
"Error converting column value to number.", e);
92 }
catch (IllegalAccessException | InvocationTargetException ex) {
94 LOGGER.log(Level.SEVERE,
"Error in getting column value.", ex);
101 boolean isRenderingAsEpoch() {
102 return this.renderAsEpoch;
synchronized static Logger getLogger(String name)