All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.extjs.gxt.ui.client.widget.table.DateTimeCellRenderer Maven / Gradle / Ivy

There is a newer version: 2.3.1-gwt22
Show newest version
/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007, 2008, Ext JS, LLC.
 * [email protected]
 * 
 * http://extjs.com/license
 */
package com.extjs.gxt.ui.client.widget.table;

import java.util.Date;

import com.extjs.gxt.ui.client.widget.Component;
import com.google.gwt.i18n.client.DateTimeFormat;

/**
 * A CellRenderer implementation for date and times.
 * 
 * @see DateTimeFormat
 */
public class DateTimeCellRenderer implements CellRenderer {

  private DateTimeFormat format;

  /**
   * Creates a date time cell renderer.
   * 
   * @param pattern the date time format
   */
  public DateTimeCellRenderer(String pattern) {
    this.format = DateTimeFormat.getFormat(pattern);
  }

  /**
   * Creates a new date time cell renderer.
   * 
   * @param format the date time format
   */
  public DateTimeCellRenderer(DateTimeFormat format) {
    this.format = format;
  }

  public String render(T item, String property, Object value) {
    if (value == null) {
      return "";
    }
    return format.format((Date) value);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy