01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.ui.client.widget.table;
09:
10: import java.util.Date;
11:
12: import com.google.gwt.i18n.client.DateTimeFormat;
13:
14: /**
15: * A <code>CellRenderer</code> implementation for date and times.
16: *
17: * @see DateTimeFormat
18: */
19: public class DateTimeCellRenderer implements CellRenderer {
20:
21: private DateTimeFormat format;
22:
23: public DateTimeCellRenderer(String pattern) {
24: this .format = DateTimeFormat.getFormat(pattern);
25: }
26:
27: public DateTimeCellRenderer(DateTimeFormat format) {
28: this .format = format;
29: }
30:
31: public String render(String property, Object value) {
32: if (value == null) {
33: return "";
34: }
35: return format.format((Date) value);
36: }
37: }
|