1 19 20 package org.netbeans.modules.tasklist.usertasks.renderers; 21 22 import java.text.SimpleDateFormat ; 23 import java.util.Date ; 24 import javax.swing.table.DefaultTableCellRenderer ; 25 26 31 public class DateTableCellRenderer extends DefaultTableCellRenderer { 32 private static SimpleDateFormat format = new SimpleDateFormat (); 33 34 public void setAsText(String s) throws java.lang.IllegalArgumentException { 36 if (s.trim().length() == 0) { 37 setValue(null); 38 return; 39 } 40 50 } 51 52 @Override 53 protected void setValue(Object value) { 54 if (value instanceof Date ) { 55 setText(format.format((Date ) value)); 56 } else if (value instanceof Long ) { 57 long v = ((Long ) value).longValue(); 58 if (v == 0) 59 setText(""); else 61 setText(format.format(new Date (v))); 62 } else { 63 setText(""); } 65 } 66 } 67 | Popular Tags |