DateCellRenderer.java :  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » components » table » renderer » Java Open Source

Java Open Source » J2EE » webwork 2.2.6 
webwork 2.2.6 » com » opensymphony » webwork » components » table » renderer » DateCellRenderer.java
/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.opensymphony.webwork.components.table.renderer;

import com.opensymphony.webwork.components.table.WebTable;

import java.text.SimpleDateFormat;


/**
 * @author $author$
 * @version $Revision: 1282 $
 */
public class DateCellRenderer extends AbstractCellRenderer {

    SimpleDateFormat _formater = new SimpleDateFormat();

    /**
     * this is the string that  SimpleDateFormat needs to display the date
     *
     * @see SimpleDateFormat
     */
    String _formatString = null;


    public DateCellRenderer() {
        super();
    }


    public String getCellValue(WebTable table, Object data, int row, int col) {
        java.util.Date cellValue = null;

        if (data == null) {
            return "";
        }

        if (data instanceof java.util.Date) {
            return _formater.format((java.util.Date) data);
        }

        return data.toString();
    }

    public void setFormatString(String format) {
        _formatString = format;
        _formater.applyPattern(_formatString);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.