<commit_before>package org.appwork.swing.exttable.columns;

import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.appwork.swing.exttable.ExtColumn;
import org.appwork.swing.exttable.ExtDefaultRowSorter;
import org.appwork.swing.exttable.ExtTableModel;

public abstract class ExtDateColumn<E> extends ExtTextColumn<E> {

    /**
     * 
     */
    private static final long serialVersionUID = -5812486934156037376L;

    private SimpleDateFormat  dateFormat;
    protected Date            date;
    protected String          badDateText      = "~";

    private StringBuffer      sb;

    /**
     * @param string
     */
    public ExtDateColumn(final String string) {
        this(string, null);
    }

    public ExtDateColumn(final String name, final ExtTableModel<E> table) {
        super(name, table);

        this.date = new Date();
        this.sb = new StringBuffer();
        try {
            this.dateFormat = new SimpleDateFormat(this.getDateFormatString()) {

                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public StringBuffer format(final Date date, final StringBuffer toAppendTo, final FieldPosition pos) {
                    ExtDateColumn.this.sb.setLength(0);
                    return super.format(date, ExtDateColumn.this.sb, pos);
                }
            };
        } catch (final Exception e) {
            this.dateFormat = new SimpleDateFormat("dd.MM.yy HH:mm") {

                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public StringBuffer format(final Date date, final StringBuffer toAppendTo, final FieldPosition pos) {
                    ExtDateColumn.this.sb.setLength(0);
                    return super.format(date, ExtDateColumn.this.sb, pos);
                }
            };
        }

        this.setRowSorter(new ExtDefaultRowSorter<E>() {

            private long a = 0;
            private long b = 0;

            @Override
            public int compare(final E o1, final E o2) {
                Date tmp = ExtDateColumn.this.getDate(o1, null);
                if (tmp != null) {
                    this.a = tmp.getTime();
                } else {
                    this.a = 0;
                }
                tmp = ExtDateColumn.this.getDate(o2, null);
                if (tmp != null) {
                    this.b = tmp.getTime();
                } else {
                    this.b = 0;
                }<commit_msg>ExtDateColumn: fixed npe because data was set to null, how should this have worked at all<commit_after>package org.appwork.swing.exttable.columns;

import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.appwork.swing.exttable.ExtColumn;
import org.appwork.swing.exttable.ExtDefaultRowSorter;
import org.appwork.swing.exttable.ExtTableModel;

public abstract class ExtDateColumn<E> extends ExtTextColumn<E> {

    /**
     * 
     */
    private static final long serialVersionUID = -5812486934156037376L;

    private SimpleDateFormat  dateFormat;
    protected Date            date;
    protected String          badDateText      = "~";

    private StringBuffer      sb;

    /**
     * @param string
     */
    public ExtDateColumn(final String string) {
        this(string, null);
    }

    public ExtDateColumn(final String name, final ExtTableModel<E> table) {
        super(name, table);

        this.date = new Date();
        this.sb = new StringBuffer();
        try {
            this.dateFormat = new SimpleDateFormat(this.getDateFormatString()) {

                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public StringBuffer format(final Date date, final StringBuffer toAppendTo, final FieldPosition pos) {
                    ExtDateColumn.this.sb.setLength(0);
                    return super.format(date, ExtDateColumn.this.sb, pos);
                }
            };
        } catch (final Exception e) {
            this.dateFormat = new SimpleDateFormat("dd.MM.yy HH:mm") {

                /**
                 * 
                 */
                private static final long serialVersionUID = 1L;

                @Override
                public StringBuffer format(final Date date, final StringBuffer toAppendTo, final FieldPosition pos) {
                    ExtDateColumn.this.sb.setLength(0);
                    return super.format(date, ExtDateColumn.this.sb, pos);
                }
            };
        }

        this.setRowSorter(new ExtDefaultRowSorter<E>() {

            private long       a    = 0;
            private long       b    = 0;
            private final Date date = new Date();

            @Override
            public int compare(final E o1, final E o2) {
                Date tmp = ExtDateColumn.this.getDate(o1, this.date);
                if (tmp != null) {
                    this.a = tmp.getTime();
                } else {
                    this.a = 0;
                }
                tmp = ExtDateColumn.this.getDate(o2, this.date);
                if (tmp != null) {
                    this.b = tmp.getTime();
                } else {
                    this.b = 0;
                }
{'fraction_non_alphanumeric': 0.08896925858951175, 'fraction_numerical': 0.011211573236889693, 'mean_word_length': 1.5244180739388407, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1459782', 'n_tokens_mistral': 1523, 'n_tokens_neox': 1401, 'n_words': 347}