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

com.cedarsolutions.client.gwt.widget.table.TimestampColumn Maven / Gradle / Ivy

There is a newer version: 5.8.4
Show newest version
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *              C E D A R
 *          S O L U T I O N S       "Software done right."
 *           S O F T W A R E
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 * Copyright (c) 2013 Kenneth J. Pronovici.
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the Apache License, Version 2.0.
 * See LICENSE for more information about the licensing terms.
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 * Author   : Kenneth J. Pronovici 
 * Language : Java 6
 * Project  : Common Java Functionality
 *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package com.cedarsolutions.client.gwt.widget.table;

import java.util.Date;

import com.cedarsolutions.util.gwt.GwtDateUtils;

/**
 * A ColumnWithName that displays a Date in standard "timestamp" format.
 * @param  the row type
 * @author Kenneth J. Pronovici 
 */
public abstract class TimestampColumn extends TypedColumn {

    /** Whether to include the time zone in the output. */
    private boolean includeZone = true;

    /** Create a column with no name. */
    public TimestampColumn() {
        super();
    }

    /** Create a column with a name taken from an enum. */
    @SuppressWarnings("rawtypes")
    public TimestampColumn(Enum name) {
        super(name);
    }

    /** Create a column with a name taken from an enum. */
    @SuppressWarnings("rawtypes")
    public TimestampColumn(Enum name, Sortable sortable) {
        super(name, sortable);
    }

    /** Create a column with a name. */
    public TimestampColumn(String name) {
        super(name);
    }

    /** Create a column with a name. */
    public TimestampColumn(String name, Sortable sortable) {
        super(name, sortable);
    }

    /** Format a non-null field value properly. */
    @Override
    protected String formatField(Date field) {
        if (this.getIncludeZone()) {
            return GwtDateUtils.formatTimestampWithZone(field);
        } else {
            return GwtDateUtils.formatTimestamp(field);
        }
    }

    /** Whether to include the time zone in the output. */
    public boolean getIncludeZone() {
        return this.includeZone;
    }

    /** Whether to include the time zone in the output. */
    public void setIncludeZone(boolean includeZone) {
        this.includeZone = includeZone;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy