Example usage for java.util Locale FRENCH

List of usage examples for java.util Locale FRENCH

Introduction

In this page you can find the example usage for java.util Locale FRENCH.

Prototype

Locale FRENCH

To view the source code for java.util Locale FRENCH.

Click Source Link

Document

Useful constant for language.

Usage

From source file:org.nuxeo.ecm.platform.usermanager.TestUserManagerResolver.java

private void checkMessage(UserManagerResolver umr) {
    for (Locale locale : Arrays.asList(Locale.FRENCH, Locale.ENGLISH)) {
        String message = umr.getConstraintErrorMessage("abc123", locale);
        assertNotNull(message);/*from   w w  w  . j  a  va  2  s . co m*/
        assertFalse(message.trim().isEmpty());
        System.out.println(message);
    }
}

From source file:org.pengyou.ooo.PublishAsDialog.java

private String formatList(String[] t) {
    String res = new String();

    if (t[2] == "COLLECTION") {
        if (t[4].length() > 21)
            res = t[4].substring(0, 20) + "";
        else//  ww w. ja  v a  2s. com
            res = t[4];
        //res = " " + res; 
        res = " " + res;
    } else {
        if (t[4].length() > 23)
            res = t[4].substring(0, 22) + "";
        else
            res = t[4];
    }

    //int l = res.length();
    while (res.length() < 25)
        res += " ";

    res += t[6];
    while (res.length() < 42)
        res += " ";

    Locale locale = Locale.FRENCH;
    Date date = null;
    String s = null;

    try {
        date = DateFormat.getDateTimeInstance().parse(t[5]);
        s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date);
        res += s;
        while (res.length() < 57)
            res += " ";
    } catch (ParseException e) {
        e.printStackTrace();
        log.log(Level.DEBUG, e.getLocalizedMessage());
    }
    date = null;
    s = null;
    try {
        date = DateFormat.getDateTimeInstance().parse(t[3]);
        s = DateFormat.getDateInstance(DateFormat.MEDIUM, locale).format(date);
        res += s;
        while (res.length() < 71)
            res += " ";
    } catch (ParseException e) {
        e.printStackTrace();
        log.log(Level.DEBUG, e.getLocalizedMessage());
    }

    return res;
}

From source file:org.yccheok.jstock.gui.MainFrame.java

/** This method is called from within the constructor to
 * initialize the form./* w  ww.  ja v  a  2  s  .  co  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    buttonGroup1 = new javax.swing.ButtonGroup();
    buttonGroup2 = new javax.swing.ButtonGroup();
    buttonGroup3 = new javax.swing.ButtonGroup();
    jComboBox1 = new AutoCompleteJComboBox();
    jPanel6 = new javax.swing.JPanel();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    jPanel8 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel10 = new javax.swing.JPanel();
    jPanel3 = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jMenuBar2 = new javax.swing.JMenuBar();
    jMenu3 = new javax.swing.JMenu();
    jMenuItem2 = new javax.swing.JMenuItem();
    jMenuItem9 = new javax.swing.JMenuItem();
    jSeparator7 = new javax.swing.JPopupMenu.Separator();
    jMenuItem11 = new javax.swing.JMenuItem();
    jMenuItem10 = new javax.swing.JMenuItem();
    jSeparator8 = new javax.swing.JPopupMenu.Separator();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenu5 = new javax.swing.JMenu();
    jMenuItem4 = new javax.swing.JMenuItem();
    jMenuItem7 = new javax.swing.JMenuItem();
    jSeparator4 = new javax.swing.JPopupMenu.Separator();
    jMenuItem15 = new javax.swing.JMenuItem();
    jMenu6 = new javax.swing.JMenu();
    jMenu10 = new javax.swing.JMenu();
    jRadioButtonMenuItem1 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem2 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem4 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem6 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem3 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem5 = new javax.swing.JRadioButtonMenuItem();
    jMenu7 = new javax.swing.JMenu();
    jMenuItem8 = new javax.swing.JMenuItem();
    jMenu9 = new javax.swing.JMenu();
    jMenu8 = new javax.swing.JMenu();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem6 = new javax.swing.JMenuItem();
    jMenu4 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jMenuItem16 = new javax.swing.JMenuItem();
    jMenuItem12 = new javax.swing.JMenuItem();
    jSeparator6 = new javax.swing.JPopupMenu.Separator();
    jMenuItem13 = new javax.swing.JMenuItem();
    jMenuItem14 = new javax.swing.JMenuItem();
    jSeparator5 = new javax.swing.JPopupMenu.Separator();
    jMenuItem5 = new javax.swing.JMenuItem();
    jMenu11 = new javax.swing.JMenu();
    jMenuItem17 = new javax.swing.JMenuItem();

    jComboBox1.setEditable(true);
    jComboBox1.setPreferredSize(new java.awt.Dimension(150, 24));
    ((AutoCompleteJComboBox) this.jComboBox1).attachStockInfoObserver(getStockInfoObserver());
    ((AutoCompleteJComboBox) this.jComboBox1).attachResultObserver(getResultObserver());
    ((AutoCompleteJComboBox) this.jComboBox1).attachMatchObserver(getMatchObserver());

    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
    setTitle(bundle.getString("MainFrame_Application_Title")); // NOI18N
    setIconImage(getMyIconImage());
    addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            formMouseClicked(evt);
        }
    });
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosed(evt);
        }

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }

        public void windowDeiconified(java.awt.event.WindowEvent evt) {
            formWindowDeiconified(evt);
        }

        public void windowIconified(java.awt.event.WindowEvent evt) {
            formWindowIconified(evt);
        }
    });
    getContentPane().setLayout(new java.awt.BorderLayout(5, 5));

    jPanel6.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jPanel6.setLayout(new java.awt.BorderLayout(5, 5));
    this.jPanel6.add(statusBar, java.awt.BorderLayout.SOUTH);
    getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH);

    jTabbedPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jTabbedPane1StateChanged(evt);
        }
    });

    jPanel8.setLayout(new java.awt.BorderLayout(5, 5));

    jTable1.setAutoCreateRowSorter(true);
    jTable1.setFont(jTable1.getFont().deriveFont(jTable1.getFont().getStyle() | java.awt.Font.BOLD,
            jTable1.getFont().getSize() + 1));
    jTable1.setModel(new StockTableModel());
    jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    this.jTable1.setDefaultRenderer(Number.class, new StockTableCellRenderer(SwingConstants.RIGHT));
    this.jTable1.setDefaultRenderer(Double.class, new StockTableCellRenderer(SwingConstants.RIGHT));
    this.jTable1.setDefaultRenderer(Object.class, new StockTableCellRenderer(SwingConstants.LEFT));

    this.jTable1.setDefaultEditor(Double.class, new NonNegativeDoubleEditor());

    this.jTable1.getModel().addTableModelListener(this.getTableModelListener());

    this.jTable1.getTableHeader().addMouseListener(new TableColumnSelectionPopupListener(1));
    this.jTable1.addMouseListener(new TableRowPopupListener());
    this.jTable1.addKeyListener(new TableKeyEventListener());
    jTable1.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            jTable1KeyPressed(evt);
        }
    });
    jScrollPane1.setViewportView(jTable1);

    jPanel8.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jLabel1.setText(bundle.getString("MainFrame_Stock")); // NOI18N
    jPanel1.add(jLabel1);

    jPanel8.add(jPanel1, java.awt.BorderLayout.NORTH);

    jPanel10.setPreferredSize(new java.awt.Dimension(328, 170));
    jPanel10.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 10, 5));

    jPanel3.setBackground(new java.awt.Color(255, 255, 255));
    jPanel3.setPreferredSize(new java.awt.Dimension(170, 160));
    jPanel3.setBorder(new org.jdesktop.swingx.border.DropShadowBorder(true));
    jPanel3.setLayout(new java.awt.BorderLayout());
    jPanel10.add(jPanel3);
    EMPTY_DYNAMIC_CHART.getChartPanel().addMouseListener(dynamicChartMouseAdapter);
    jPanel3.add(EMPTY_DYNAMIC_CHART.getChartPanel(), java.awt.BorderLayout.CENTER);

    jPanel8.add(jPanel10, java.awt.BorderLayout.SOUTH);

    jTabbedPane1.addTab(bundle.getString("MainFrame_Title"), jPanel8); // NOI18N

    getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);

    jPanel2.setLayout(new java.awt.GridLayout(2, 1));
    getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH);

    jMenu3.setText(bundle.getString("MainFrame_File")); // NOI18N

    jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/project_open.png"))); // NOI18N
    jMenuItem2.setText(bundle.getString("MainFrame_Open...")); // NOI18N
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem2);

    jMenuItem9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filesave.png"))); // NOI18N
    jMenuItem9.setText(bundle.getString("MainFrame_SaveAs...")); // NOI18N
    jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem9ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem9);
    jMenu3.add(jSeparator7);

    jMenuItem11.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/images/16x16/download_from_cloud.png"))); // NOI18N
    jMenuItem11.setText(bundle.getString("MainFrame_OpenFromCloud...")); // NOI18N
    jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem11ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem11);

    jMenuItem10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/upload_to_cloud.png"))); // NOI18N
    jMenuItem10.setText(bundle.getString("MainFrame_SaveToCloud...")); // NOI18N
    jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem10ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem10);
    jMenu3.add(jSeparator8);

    jMenuItem1.setText(bundle.getString("MainFrame_Exit")); // NOI18N
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem1);

    jMenuBar2.add(jMenu3);

    jMenu5.setText(bundle.getString("MainFrame_Edit")); // NOI18N

    jMenuItem4.setText(bundle.getString("MainFrame_AddStocks...")); // NOI18N
    jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem4ActionPerformed(evt);
        }
    });
    jMenu5.add(jMenuItem4);

    jMenuItem7.setText(bundle.getString("MainFrame_ClearAllStocks")); // NOI18N
    jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem7ActionPerformed(evt);
        }
    });
    jMenu5.add(jMenuItem7);
    jMenu5.add(jSeparator4);

    jMenuItem15.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem15.setText(bundle.getString("MainFrame_RefreshStockPrices")); // NOI18N
    jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem15ActionPerformed(evt);
        }
    });
    jMenu5.add(jMenuItem15);

    jMenuBar2.add(jMenu5);

    jMenu6.setText(bundle.getString("MainFrame_Country")); // NOI18N
    jMenuBar2.add(jMenu6);

    jMenu10.setText(bundle.getString("MainFrame_Language")); // NOI18N

    buttonGroup3.add(jRadioButtonMenuItem1);
    jRadioButtonMenuItem1.setSelected(true);
    jRadioButtonMenuItem1.setText(Locale.ENGLISH.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem1ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem1);

    buttonGroup3.add(jRadioButtonMenuItem2);
    jRadioButtonMenuItem2.setText(Locale.SIMPLIFIED_CHINESE.getDisplayName(Locale.getDefault()));
    jRadioButtonMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem2ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem2);

    buttonGroup3.add(jRadioButtonMenuItem4);
    jRadioButtonMenuItem4.setText(Locale.TRADITIONAL_CHINESE.getDisplayName(Locale.getDefault()));
    jRadioButtonMenuItem4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem4ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem4);

    buttonGroup3.add(jRadioButtonMenuItem6);
    jRadioButtonMenuItem6.setText(Locale.FRENCH.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem6ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem6);

    buttonGroup3.add(jRadioButtonMenuItem3);
    jRadioButtonMenuItem3.setText(Locale.GERMAN.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem3ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem3);

    buttonGroup3.add(jRadioButtonMenuItem5);
    jRadioButtonMenuItem5.setText(Locale.ITALIAN.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem5ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem5);

    jMenuBar2.add(jMenu10);

    jMenu7.setText(bundle.getString("MainFrame_Database")); // NOI18N

    jMenuItem8.setText(bundle.getString("MainFrame_StockDatabase...")); // NOI18N
    jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem8ActionPerformed(evt);
        }
    });
    jMenu7.add(jMenuItem8);

    jMenuBar2.add(jMenu7);

    jMenu9.setText(bundle.getString("MainFrame_Watchlist")); // NOI18N
    jMenu9.addMenuListener(new javax.swing.event.MenuListener() {
        public void menuCanceled(javax.swing.event.MenuEvent evt) {
        }

        public void menuDeselected(javax.swing.event.MenuEvent evt) {
        }

        public void menuSelected(javax.swing.event.MenuEvent evt) {
            jMenu9MenuSelected(evt);
        }
    });
    jMenuBar2.add(jMenu9);

    jMenu8.setText(bundle.getString("MainFrame_Portfolio")); // NOI18N
    jMenu8.addMenuListener(new javax.swing.event.MenuListener() {
        public void menuCanceled(javax.swing.event.MenuEvent evt) {
        }

        public void menuDeselected(javax.swing.event.MenuEvent evt) {
        }

        public void menuSelected(javax.swing.event.MenuEvent evt) {
            jMenu8MenuSelected(evt);
        }
    });
    jMenuBar2.add(jMenu8);

    jMenu1.setText(bundle.getString("MainFrame_Options")); // NOI18N

    jMenuItem6.setText(bundle.getString("MainFrame_Options...")); // NOI18N
    jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem6ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem6);

    jMenuBar2.add(jMenu1);

    jMenu4.setText(bundle.getString("MainFrame_LooknFeel")); // NOI18N
    jMenuBar2.add(jMenu4);

    jMenu2.setText(bundle.getString("MainFrame_Help")); // NOI18N

    jMenuItem3.setText(bundle.getString("MainFrame_OnlineHelp")); // NOI18N
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem3ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem3);

    jMenuItem16.setText(bundle.getString("MainFrame_KeyboardShortcuts")); // NOI18N
    jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem16ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem16);

    jMenuItem12.setText(bundle.getString("MainFrame_Calculator")); // NOI18N
    jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem12ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem12);
    jMenu2.add(jSeparator6);

    jMenuItem13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/smile2.png"))); // NOI18N
    jMenuItem13.setText(bundle.getString("MainFrame_DonateToJStock")); // NOI18N
    jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem13ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem13);

    jMenuItem14.setText(bundle.getString("MainFrame_ContributeToJStock")); // NOI18N
    jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem14ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem14);
    jMenu2.add(jSeparator5);

    jMenuItem5.setText(bundle.getString("MainFrame_About...")); // NOI18N
    jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem5ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem5);

    jMenuBar2.add(jMenu2);

    jMenu11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/android-small.png"))); // NOI18N
    jMenu11.setText(bundle.getString("MainFrame_Android")); // NOI18N
    jMenu11.setFont(jMenu11.getFont().deriveFont(jMenu11.getFont().getStyle() | java.awt.Font.BOLD));

    jMenuItem17.setText(bundle.getString("MainFrame_DownloadJStockAndroid")); // NOI18N
    jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem17ActionPerformed(evt);
        }
    });
    jMenu11.add(jMenuItem17);

    jMenuBar2.add(jMenu11);

    setJMenuBar(jMenuBar2);

    setSize(new java.awt.Dimension(952, 478));
    setLocationRelativeTo(null);
}

From source file:org.yccheok.jstock.gui.JStock.java

/** This method is called from within the constructor to
 * initialize the form./*from   w  w w.ja v  a 2 s . co  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    buttonGroup1 = new javax.swing.ButtonGroup();
    buttonGroup2 = new javax.swing.ButtonGroup();
    buttonGroup3 = new javax.swing.ButtonGroup();
    buttonGroup4 = new javax.swing.ButtonGroup();
    jComboBox1 = new AutoCompleteJComboBox();
    jPanel6 = new javax.swing.JPanel();
    jTabbedPane1 = new javax.swing.JTabbedPane();
    jPanel8 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTable1 = new javax.swing.JTable();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel10 = new javax.swing.JPanel();
    jPanel3 = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jMenuBar2 = new javax.swing.JMenuBar();
    jMenu3 = new javax.swing.JMenu();
    jMenuItem2 = new javax.swing.JMenuItem();
    jMenuItem9 = new javax.swing.JMenuItem();
    jSeparator7 = new javax.swing.JPopupMenu.Separator();
    jMenuItem11 = new javax.swing.JMenuItem();
    jMenuItem10 = new javax.swing.JMenuItem();
    jSeparator8 = new javax.swing.JPopupMenu.Separator();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenu5 = new javax.swing.JMenu();
    jMenuItem4 = new javax.swing.JMenuItem();
    jMenuItem7 = new javax.swing.JMenuItem();
    jSeparator4 = new javax.swing.JPopupMenu.Separator();
    jMenuItem15 = new javax.swing.JMenuItem();
    jMenu6 = new javax.swing.JMenu();
    jMenu10 = new javax.swing.JMenu();
    jRadioButtonMenuItem1 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem2 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem4 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem6 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem3 = new javax.swing.JRadioButtonMenuItem();
    jRadioButtonMenuItem5 = new javax.swing.JRadioButtonMenuItem();
    jMenu7 = new javax.swing.JMenu();
    jMenuItem8 = new javax.swing.JMenuItem();
    jMenu9 = new javax.swing.JMenu();
    jMenu8 = new javax.swing.JMenu();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem6 = new javax.swing.JMenuItem();
    jMenu4 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();
    jMenuItem16 = new javax.swing.JMenuItem();
    jMenuItem12 = new javax.swing.JMenuItem();
    jSeparator6 = new javax.swing.JPopupMenu.Separator();
    jMenuItem13 = new javax.swing.JMenuItem();
    jMenuItem14 = new javax.swing.JMenuItem();
    jSeparator5 = new javax.swing.JPopupMenu.Separator();
    jMenuItem5 = new javax.swing.JMenuItem();
    jMenu11 = new javax.swing.JMenu();
    jMenuItem17 = new javax.swing.JMenuItem();

    jComboBox1.setEditable(true);
    jComboBox1.setPreferredSize(new java.awt.Dimension(150, 24));
    ((AutoCompleteJComboBox) this.jComboBox1).attachStockInfoObserver(getStockInfoObserver());
    ((AutoCompleteJComboBox) this.jComboBox1).attachDispObserver(getDispObserver());

    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/yccheok/jstock/data/gui"); // NOI18N
    setTitle(bundle.getString("MainFrame_Application_Title")); // NOI18N
    setIconImage(getMyIconImage());
    addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            formMouseClicked(evt);
        }
    });
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            formWindowClosed(evt);
        }

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }

        public void windowDeiconified(java.awt.event.WindowEvent evt) {
            formWindowDeiconified(evt);
        }

        public void windowIconified(java.awt.event.WindowEvent evt) {
            formWindowIconified(evt);
        }
    });
    getContentPane().setLayout(new java.awt.BorderLayout(5, 5));

    jPanel6.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jPanel6.setLayout(new java.awt.BorderLayout(5, 5));
    this.jPanel6.add(statusBar, java.awt.BorderLayout.SOUTH);
    getContentPane().add(jPanel6, java.awt.BorderLayout.SOUTH);

    jTabbedPane1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jTabbedPane1.addChangeListener(new javax.swing.event.ChangeListener() {
        public void stateChanged(javax.swing.event.ChangeEvent evt) {
            jTabbedPane1StateChanged(evt);
        }
    });

    jPanel8.setLayout(new java.awt.BorderLayout(5, 5));

    jTable1.setAutoCreateRowSorter(true);
    jTable1.setFont(jTable1.getFont().deriveFont(jTable1.getFont().getStyle() | java.awt.Font.BOLD,
            jTable1.getFont().getSize() + 1));
    jTable1.setModel(new StockTableModel());
    jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    this.jTable1.setDefaultRenderer(Number.class, new StockTableCellRenderer(SwingConstants.RIGHT));
    this.jTable1.setDefaultRenderer(Double.class, new StockTableCellRenderer(SwingConstants.RIGHT));
    this.jTable1.setDefaultRenderer(Object.class, new StockTableCellRenderer(SwingConstants.LEFT));

    this.jTable1.setDefaultEditor(Double.class, new NonNegativeDoubleEditor());

    this.jTable1.getModel().addTableModelListener(this.getTableModelListener());

    this.jTable1.getTableHeader().addMouseListener(new TableColumnSelectionPopupListener(1));
    this.jTable1.addMouseListener(new TableMouseAdapter());
    this.jTable1.addKeyListener(new TableKeyEventListener());

    if (jStockOptions.useLargeFont()) {
        this.jTable1.setRowHeight((int) (this.jTable1.getRowHeight() * Constants.FONT_ENLARGE_FACTOR));
    }
    jTable1.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            jTable1KeyPressed(evt);
        }
    });
    jScrollPane1.setViewportView(jTable1);

    jPanel8.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jLabel1.setText(bundle.getString("MainFrame_Stock")); // NOI18N
    jPanel1.add(jLabel1);

    jPanel8.add(jPanel1, java.awt.BorderLayout.NORTH);

    jPanel10.setPreferredSize(new java.awt.Dimension(328, 170));
    jPanel10.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 10, 5));

    jPanel3.setBackground(new java.awt.Color(255, 255, 255));
    jPanel3.setPreferredSize(new java.awt.Dimension(170, 160));
    jPanel3.setBorder(new org.jdesktop.swingx.border.DropShadowBorder(true));
    jPanel3.setLayout(new java.awt.BorderLayout());
    jPanel10.add(jPanel3);
    EMPTY_DYNAMIC_CHART.getChartPanel().addMouseListener(dynamicChartMouseAdapter);
    jPanel3.add(EMPTY_DYNAMIC_CHART.getChartPanel(), java.awt.BorderLayout.CENTER);

    jPanel8.add(jPanel10, java.awt.BorderLayout.SOUTH);

    jTabbedPane1.addTab(bundle.getString("MainFrame_Title"), jPanel8); // NOI18N

    getContentPane().add(jTabbedPane1, java.awt.BorderLayout.CENTER);

    jPanel2.setLayout(new java.awt.GridLayout(2, 1));
    getContentPane().add(jPanel2, java.awt.BorderLayout.NORTH);

    jMenu3.setText(bundle.getString("MainFrame_File")); // NOI18N

    jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/project_open.png"))); // NOI18N
    jMenuItem2.setText(bundle.getString("MainFrame_Open...")); // NOI18N
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem2);

    jMenuItem9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/filesave.png"))); // NOI18N
    jMenuItem9.setText(bundle.getString("MainFrame_SaveAs...")); // NOI18N
    jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem9ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem9);
    jMenu3.add(jSeparator7);

    jMenuItem11.setIcon(
            new javax.swing.ImageIcon(getClass().getResource("/images/16x16/download_from_cloud.png"))); // NOI18N
    jMenuItem11.setText(bundle.getString("MainFrame_OpenFromCloud...")); // NOI18N
    jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem11ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem11);

    jMenuItem10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/upload_to_cloud.png"))); // NOI18N
    jMenuItem10.setText(bundle.getString("MainFrame_SaveToCloud...")); // NOI18N
    jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem10ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem10);
    jMenu3.add(jSeparator8);

    jMenuItem1.setText(bundle.getString("MainFrame_Exit")); // NOI18N
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
        }
    });
    jMenu3.add(jMenuItem1);

    jMenuBar2.add(jMenu3);

    jMenu5.setText(bundle.getString("MainFrame_Edit")); // NOI18N

    jMenuItem4.setText(bundle.getString("MainFrame_AddStocks...")); // NOI18N
    jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem4ActionPerformed(evt);
        }
    });
    jMenu5.add(jMenuItem4);

    jMenuItem7.setText(bundle.getString("MainFrame_ClearAllStocks")); // NOI18N
    jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem7ActionPerformed(evt);
        }
    });
    jMenu5.add(jMenuItem7);
    jMenu5.add(jSeparator4);

    jMenuItem15.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem15.setText(bundle.getString("MainFrame_RefreshStockPrices")); // NOI18N
    jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem15ActionPerformed(evt);
        }
    });
    jMenu5.add(jMenuItem15);

    jMenuBar2.add(jMenu5);

    jMenu6.setText(bundle.getString("MainFrame_Country")); // NOI18N
    jMenu6.addMenuListener(new javax.swing.event.MenuListener() {
        public void menuCanceled(javax.swing.event.MenuEvent evt) {
        }

        public void menuDeselected(javax.swing.event.MenuEvent evt) {
        }

        public void menuSelected(javax.swing.event.MenuEvent evt) {
            jMenu6MenuSelected(evt);
        }
    });
    jMenuBar2.add(jMenu6);

    jMenu10.setText(bundle.getString("MainFrame_Language")); // NOI18N

    buttonGroup3.add(jRadioButtonMenuItem1);
    jRadioButtonMenuItem1.setSelected(true);
    jRadioButtonMenuItem1.setText(Locale.ENGLISH.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem1ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem1);

    buttonGroup3.add(jRadioButtonMenuItem2);
    jRadioButtonMenuItem2.setText(Locale.SIMPLIFIED_CHINESE.getDisplayName(Locale.getDefault()));
    jRadioButtonMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem2ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem2);

    buttonGroup3.add(jRadioButtonMenuItem4);
    jRadioButtonMenuItem4.setText(Locale.TRADITIONAL_CHINESE.getDisplayName(Locale.getDefault()));
    jRadioButtonMenuItem4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem4ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem4);

    buttonGroup3.add(jRadioButtonMenuItem6);
    jRadioButtonMenuItem6.setText(Locale.FRENCH.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem6ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem6);

    buttonGroup3.add(jRadioButtonMenuItem3);
    jRadioButtonMenuItem3.setText(Locale.GERMAN.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem3ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem3);

    buttonGroup3.add(jRadioButtonMenuItem5);
    jRadioButtonMenuItem5.setText(Locale.ITALIAN.getDisplayLanguage(Locale.getDefault()));
    jRadioButtonMenuItem5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jRadioButtonMenuItem5ActionPerformed(evt);
        }
    });
    jMenu10.add(jRadioButtonMenuItem5);

    jMenuBar2.add(jMenu10);

    jMenu7.setText(bundle.getString("MainFrame_Database")); // NOI18N

    jMenuItem8.setText(bundle.getString("MainFrame_StockDatabase...")); // NOI18N
    jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem8ActionPerformed(evt);
        }
    });
    jMenu7.add(jMenuItem8);

    jMenuBar2.add(jMenu7);

    jMenu9.setText(bundle.getString("MainFrame_Watchlist")); // NOI18N
    jMenu9.addMenuListener(new javax.swing.event.MenuListener() {
        public void menuCanceled(javax.swing.event.MenuEvent evt) {
        }

        public void menuDeselected(javax.swing.event.MenuEvent evt) {
        }

        public void menuSelected(javax.swing.event.MenuEvent evt) {
            jMenu9MenuSelected(evt);
        }
    });
    jMenuBar2.add(jMenu9);

    jMenu8.setText(bundle.getString("MainFrame_Portfolio")); // NOI18N
    jMenu8.addMenuListener(new javax.swing.event.MenuListener() {
        public void menuCanceled(javax.swing.event.MenuEvent evt) {
        }

        public void menuDeselected(javax.swing.event.MenuEvent evt) {
        }

        public void menuSelected(javax.swing.event.MenuEvent evt) {
            jMenu8MenuSelected(evt);
        }
    });
    jMenuBar2.add(jMenu8);

    jMenu1.setText(bundle.getString("MainFrame_Options")); // NOI18N

    jMenuItem6.setText(bundle.getString("MainFrame_Options...")); // NOI18N
    jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem6ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem6);

    jMenuBar2.add(jMenu1);

    jMenu4.setText(bundle.getString("MainFrame_LooknFeel")); // NOI18N
    jMenuBar2.add(jMenu4);

    jMenu2.setText(bundle.getString("MainFrame_Help")); // NOI18N

    jMenuItem3.setText(bundle.getString("MainFrame_OnlineHelp")); // NOI18N
    jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem3ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem3);

    jMenuItem16.setText(bundle.getString("MainFrame_KeyboardShortcuts")); // NOI18N
    jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem16ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem16);

    jMenuItem12.setText(bundle.getString("MainFrame_Calculator")); // NOI18N
    jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem12ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem12);
    jMenu2.add(jSeparator6);

    jMenuItem13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/smile2.png"))); // NOI18N
    jMenuItem13.setText(bundle.getString("MainFrame_DonateToJStock")); // NOI18N
    jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem13ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem13);

    jMenuItem14.setText(bundle.getString("MainFrame_ContributeToJStock")); // NOI18N
    jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem14ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem14);
    jMenu2.add(jSeparator5);

    jMenuItem5.setText(bundle.getString("MainFrame_About...")); // NOI18N
    jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem5ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem5);

    jMenuBar2.add(jMenu2);

    jMenu11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/16x16/android-small.png"))); // NOI18N
    jMenu11.setText(bundle.getString("MainFrame_Android")); // NOI18N
    jMenu11.setFont(jMenu11.getFont().deriveFont(jMenu11.getFont().getStyle() | java.awt.Font.BOLD));

    jMenuItem17.setText(bundle.getString("MainFrame_DownloadJStockAndroid")); // NOI18N
    jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem17ActionPerformed(evt);
        }
    });
    jMenu11.add(jMenuItem17);

    jMenuBar2.add(jMenu11);

    setJMenuBar(jMenuBar2);

    setSize(new java.awt.Dimension(952, 478));
    setLocationRelativeTo(null);
}

From source file:org.openmrs.module.diagnosiscapturerwanda.DiagnosisHomepageController.java

@RequestMapping(value = "/module/diagnosiscapturerwanda/cleanupConcepts")
public void cleanupConcepts(HttpServletResponse response, ModelMap model,
        @RequestParam("startConceptId") Integer startConceptId,
        @RequestParam("endConceptId") Integer endConceptId) throws Exception {

    for (Concept c : Context.getConceptService().getAllConcepts()) {

        if (c.getConceptId() >= startConceptId && c.getConceptId() <= endConceptId) {
            try {
                boolean needsUpdate = false;

                boolean foundFullySpecified = false;
                for (ConceptName cn : c.getNames()) {
                    if (cn.isFullySpecifiedName()) {
                        foundFullySpecified = true;
                    }//from   ww  w .j a  v a2s  .  c  o  m
                }

                // activating voided fully specified names when there are no non-voided fully specified names
                if (!foundFullySpecified) {
                    for (ConceptName cn : c.getNames(true)) {
                        if (cn.isFullySpecifiedName() && cn.isVoided()) {
                            cn.setVoided(false);
                            cn.setVoidedBy(null);
                            cn.setVoidReason(null);
                            cn.setDateVoided(null);
                            System.out.println(
                                    "Updating " + c.getId() + " to have at least one fully specified name");
                            needsUpdate = true;
                            break;
                        }
                    }
                }

                //removing duplicate concept maps
                Set<ConceptMap> newList = new HashSet<ConceptMap>();
                Iterator<ConceptMap> iterCM = c.getConceptMappings().iterator();
                while (iterCM.hasNext()) {
                    ConceptMap cm = iterCM.next();
                    if (containsDuplicateMapping(newList, cm)) {
                        iterCM.remove();
                        c.removeConceptMapping(cm);
                        needsUpdate = true;
                        System.out.println("Removing duplicate concept map for " + c.getId());
                    } else {
                        newList.add(cm);
                    }
                }

                // removing leading and trailing whitespace from names
                for (ConceptName cn : c.getNames(true)) {
                    if (!cn.getName().equalsIgnoreCase(cn.getName().trim())) {
                        cn.setName(cn.getName().trim());
                        needsUpdate = true;
                    }
                }

                // removing duplicate names in locale:
                ConceptName fullySpecifiedFr = null;
                ConceptName fullySpecifiedEn = null;
                List<String> unmarkedNames = new ArrayList<String>();

                for (ConceptName cn : c.getNames()) {
                    if (OpenmrsUtil.nullSafeEquals(cn.getConceptNameType(), ConceptNameType.FULLY_SPECIFIED)
                            && cn.getLocale().equals(Locale.ENGLISH)) {
                        fullySpecifiedEn = cn;
                    }
                    if (OpenmrsUtil.nullSafeEquals(cn.getConceptNameType(), ConceptNameType.FULLY_SPECIFIED)
                            && cn.getLocale().equals(Locale.FRENCH)) {
                        fullySpecifiedFr = cn;
                    }
                }

                Iterator<ConceptName> iterx = c.getNames().iterator();
                while (iterx.hasNext()) {
                    ConceptName cn = iterx.next();

                    if (((cn.getLocale().equals(Locale.ENGLISH)
                            && !OpenmrsUtil
                                    .nullSafeEquals(cn.getConceptNameType(), ConceptNameType.FULLY_SPECIFIED)
                            && fullySpecifiedEn != null
                            && cn.getName().trim().toLowerCase()
                                    .equals(fullySpecifiedEn.getName().trim().toLowerCase())))
                            || ((cn.getLocale().equals(Locale.FRENCH)
                                    && !OpenmrsUtil.nullSafeEquals(cn.getConceptNameType(),
                                            ConceptNameType.FULLY_SPECIFIED)
                                    && fullySpecifiedFr != null
                                    && cn.getName().trim().toLowerCase()
                                            .equals(fullySpecifiedFr.getName().trim().toLowerCase())))
                            || ((unmarkedNames.contains(cn.getName().toUpperCase())
                                    && cn.getConceptNameType() == null))

                    ) {
                        iterx.remove();
                        c.removeName(cn);
                        System.out.println("Removing duplicate name in locale for concept " + c.getId());
                        needsUpdate = true;
                    } else if (cn.getConceptNameType() == null) {
                        unmarkedNames.add(cn.getName().toUpperCase());
                    }
                }

                // removing empty concept descriptions
                Iterator<ConceptDescription> iterCD = c.getDescriptions().iterator();
                while (iterCD.hasNext()) {
                    ConceptDescription cd = iterCD.next();
                    if (cd.getDescription() == null || cd.getDescription().trim().equals("")) {
                        iterCD.remove();
                        c.removeDescription(cd);
                        needsUpdate = true;
                        System.out.println("Removing empty concept description on " + c.getId());
                    }
                }

                //cleaning out empty concept names
                Iterator<ConceptName> iter = c.getNames(true).iterator();
                while (iter.hasNext()) {
                    ConceptName cn = iter.next();
                    if (cn.getName() == null || cn.getName().trim().equals("")) {
                        iter.remove();
                        c.removeName(cn);
                        System.out.println("Removing empty concept name");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f63a2750-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName(
                                "INFECTION OPPORTUNISTE OU COMORBIDIT ACTUELLES, CONFIRMES OU PRSUMES, NON-COD");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("3e0b767c-26fe-102b-80cb-0017a47871b2")) {
                        cn.setName("SEXUALLY TRANSMITTED INFECTION DIAGNOSIS");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f7278a40-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("diabte sucr");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f6d53c2c-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("de transfert de sortie");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f6200140-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("tuberculose mycobactries pulmonaire");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f67bd736-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("quelquefois");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f7695aa6-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("PARTENAIRES SEXUELS MULTIPLES PARTENAIRE");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f777474c-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("DE LA MENOPAUSE");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f6937f26-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("EXAMEN PULMONAIRE CONSTRUCT");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f6f2c0c6-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("EXAMEN PULMONAIRE");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("3e0b77e4-26fe-102b-80cb-0017a47871b2")) {
                        iter.remove();
                        c.removeName(cn);
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f5991072-d5db-102d-ad2a-000c29c2a5d7")) {
                        iter.remove();
                        c.removeName(cn);
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("94adc2e8-07d4-102c-b5fa-0017a47871b2")) {
                        iter.remove();
                        c.removeName(cn);
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f598d8c8-d5db-102d-ad2a-000c29c2a5d7")) {
                        iter.remove();
                        c.removeName(cn);
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("3e142ba0-26fe-102b-80cb-0017a47871b2")) {
                        cn.setName("pour bicyclette");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f67bf0ae-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("aucun moment");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f61fb0d2-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("TUBERCULOSE EXTRA PULMONAIRE");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f67ba1c6-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("trs bon");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("dddf1d1a-3a6d-4705-80a6-e2921874a2d4")) {
                        iter.remove();
                        c.removeName(cn);
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f6ec9124-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("POST-OPRATOIRE");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("3e1aa124-26fe-102b-80cb-0017a47871b2")) {
                        iter.remove();
                        c.removeName(cn);
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("3e1616ae-26fe-102b-80cb-0017a47871b2")) {
                        cn.setName("IS THIS PERSON AN ORPHAN");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("3e177df0-26fe-102b-80cb-0017a47871b2")) {
                        cn.setName("TO WHERE WAS THE PATIENT HOSPITALIZED");
                        needsUpdate = true;
                    } else if (cn.getUuid().equals("f560a62e-d5db-102d-ad2a-000c29c2a5d7")) {
                        cn.setName("RADIOGRAPHIE - PULMONAIRE");
                        needsUpdate = true;
                    }
                }

                if (needsUpdate) {
                    if ((c.getNames() == null || c.getNames().size() == 0) && c.isRetired()) {//if there are no names
                        try {
                            Context.getConceptService().purgeConcept(c);
                        } catch (Exception ex) {
                            ConceptName cn = new ConceptName();
                            cn.setConcept(c);
                            cn.setConceptNameType(ConceptNameType.FULLY_SPECIFIED);
                            cn.setCreator(Context.getAuthenticatedUser());
                            cn.setDateCreated(new Date());
                            cn.setLocale(Locale.ENGLISH);
                            cn.setLocalePreferred(true);
                            cn.setName("Placeholder name for 1.9 concept validator for a dead concept"
                                    + c.getId());
                            cn.setVoided(false);
                            c.addName(cn);
                            for (ConceptName cnTmp : c.getNames(true)) {
                                cnTmp.getTags();
                            }
                            System.out.println("Saving Concept with new ConceptName for " + c.getId());
                            Context.getConceptService().updateConceptIndex(c);

                            c = Context.getConceptService().saveConcept(c);
                        }
                    } else {
                        System.out.println("Saving Concept " + c.getId());
                        Context.getConceptService().updateConceptIndex(c);
                        c = Context.getConceptService().saveConcept(c);
                    }
                }
            } catch (Exception e) {
                response.getWriter().write("Error: " + c.getConceptId() + ": " + e.getMessage());
            }
        }
    }

    response.getWriter().write("Completed cleaning up concepts from " + startConceptId + " to " + endConceptId);
}

From source file:fr.landel.utils.commons.StringUtilsTest.java

/**
 * Test method for {@link StringUtils#format} .
 *//*from  w  ww  .j  av a  2s .  c o  m*/
@Test
public void testFormat() {
    final Locale defaultLocale = Locale.getDefault();
    Locale.setDefault(Locale.US);

    Object[] parameters = new Object[] { "param1", "param2" };
    Object[] arguments = new Object[] { 1.025f, "arg2", "arg3" };

    assertEquals("1.025 'param1' 'param2' '1.02' 'param1' 'arg2' 'arg3'",
            StringUtils.format("%s '%s*' '%s*' '%1$.2f' '%1$s*' '%s' '%s'", parameters, arguments));

    assertEquals("1.025 'param1' 'param2' '1,02' 'param1' 'arg2' 'arg3'", StringUtils.format(Locale.FRENCH,
            "%s '%s*' '%s*' '%1$.2f' '%1$s*' '%s' '%s'", parameters, arguments));

    Locale.setDefault(defaultLocale);
}

From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java

private String getFormatedDate(String dateString) {
    // format date
    SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    SimpleDateFormat formatter = new SimpleDateFormat("EEEE dd MMMM - HH:mm", Locale.FRENCH);
    try {/*from   w ww  . ja  v  a 2  s. co  m*/
        return formatter.format(parser.parse(dateString));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return dateString;
}

From source file:org.alfresco.filesys.repo.ContentDiskDriverTest.java

/**
 * This test tries to simulate the shuffling that is done by MS Word 2003 upon file save
 * /*from ww  w.  jav  a  2 s  .co m*/
 * a) TEST.DOC
 * b) Save to ~WRDnnnn.TMP
 * c) Delete ~WRLnnnn.TMP
 * d) Rename TEST.DOC ~WDLnnnn.TMP
 * e) Delete TEST.DOC
 * f) Rename ~WRDnnnn.TMP to TEST.DOC
 * g) Delete ~WRLnnnn.TMP
 * 
 * We need to check that properties, aspects, primary assocs, secondary assocs, peer assocs, node type, 
 * version history, creation date are maintained.
 */
public void testScenarioMSWord2003SaveShuffle() throws Exception {
    logger.debug("testScenarioMSWord2003SaveShuffle");
    final String FILE_NAME = "TEST.DOC";
    final String FILE_TITLE = "Test document";
    final String FILE_DESCRIPTION = "This is a test document to test CIFS shuffle";
    final String FILE_OLD_TEMP = "~WRL0002.TMP";
    final String FILE_NEW_TEMP = "~WRD0002.TMP";

    final QName RESIDUAL_MTTEXT = QName.createQName("{gsxhjsx}", "whatever");

    class TestContext {
        NetworkFile firstFileHandle;
        NetworkFile newFileHandle;
        NetworkFile oldFileHandle;

        NodeRef testNodeRef; // node ref of test.doc

        Serializable testCreatedDate;
    }
    ;

    final TestContext testContext = new TestContext();

    final String TEST_DIR = TEST_ROOT_DOS_PATH + "\\testScenarioMSWord2003SaveShuffle";

    ServerConfiguration scfg = new ServerConfiguration("testServer");
    TestServer testServer = new TestServer("testServer", scfg);
    final SrvSession testSession = new TestSrvSession(666, testServer, "test", "remoteName");
    DiskSharedDevice share = getDiskSharedDevice();
    final TreeConnection testConnection = testServer.getTreeConnection(share);

    final RetryingTransactionHelper tran = transactionService.getRetryingTransactionHelper();

    /**
     * Clean up just in case garbage is left from a previous run
     */
    RetryingTransactionCallback<Void> deleteGarbageFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
            return null;
        }
    };

    /**
     * Create a file in the test directory
     */

    try {
        tran.doInTransaction(deleteGarbageFileCB);
    } catch (Exception e) {
        // expect to go here
    }

    RetryingTransactionCallback<Void> createFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {

            /**
             * Create the test directory we are going to use 
             */
            FileOpenParams createRootDirParams = new FileOpenParams(TEST_ROOT_DOS_PATH, 0, AccessMode.ReadWrite,
                    FileAttribute.NTNormal, 0);
            FileOpenParams createDirParams = new FileOpenParams(TEST_DIR, 0, AccessMode.ReadWrite,
                    FileAttribute.NTNormal, 0);
            driver.createDirectory(testSession, testConnection, createRootDirParams);
            driver.createDirectory(testSession, testConnection, createDirParams);

            /**
             * Create the file we are going to use
             */
            FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NAME, 0,
                    AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
            testContext.firstFileHandle = driver.createFile(testSession, testConnection, createFileParams);
            assertNotNull(testContext.firstFileHandle);

            // now load up the node with lots of other stuff that we will test to see if it gets preserved during the
            // shuffle.
            testContext.testNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);

            // test non CM namespace property
            nodeService.setProperty(testContext.testNodeRef, TransferModel.PROP_ENABLED, true);
            // test CM property not related to an aspect
            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_ADDRESSEE, "Fred");

            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_TITLE, FILE_TITLE);
            nodeService.setProperty(testContext.testNodeRef, ContentModel.PROP_DESCRIPTION, FILE_DESCRIPTION);

            /**
             * MLText value - also a residual value in a non cm namespace
             */
            MLText mltext = new MLText();
            mltext.addValue(Locale.FRENCH, "Bonjour");
            mltext.addValue(Locale.ENGLISH, "Hello");
            mltext.addValue(Locale.ITALY, "Buongiorno");
            mlAwareNodeService.setProperty(testContext.testNodeRef, RESIDUAL_MTTEXT, mltext);

            // classifiable chosen since its not related to any properties.
            nodeService.addAspect(testContext.testNodeRef, ContentModel.ASPECT_CLASSIFIABLE, null);
            //nodeService.createAssociation(testContext.testNodeRef, targetRef, assocTypeQName);

            return null;
        }
    };
    tran.doInTransaction(createFileCB, false, true);

    /**
     * Write some content to the test file
     */
    RetryingTransactionCallback<Void> writeFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            String testContent = "MS Word 2003 shuffle test";
            byte[] testContentBytes = testContent.getBytes();
            testContext.firstFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
            testContext.firstFileHandle.close();

            testContext.testCreatedDate = nodeService.getProperty(testContext.testNodeRef,
                    ContentModel.PROP_CREATED);

            MLText multi = (MLText) mlAwareNodeService.getProperty(testContext.testNodeRef, RESIDUAL_MTTEXT);
            multi.getValues();

            return null;
        }
    };
    tran.doInTransaction(writeFileCB, false, true);

    /**
     * b) Save the new file
     */
    RetryingTransactionCallback<Void> saveNewFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            FileOpenParams createFileParams = new FileOpenParams(TEST_DIR + "\\" + FILE_NEW_TEMP, 0,
                    AccessMode.ReadWrite, FileAttribute.NTNormal, 0);
            testContext.newFileHandle = driver.createFile(testSession, testConnection, createFileParams);
            assertNotNull(testContext.newFileHandle);
            String testContent = "MS Word 2003 shuffle test This is new content";
            byte[] testContentBytes = testContent.getBytes();
            testContext.newFileHandle.writeFile(testContentBytes, testContentBytes.length, 0, 0);
            testContext.newFileHandle.close();

            return null;
        }
    };
    tran.doInTransaction(saveNewFileCB, false, true);

    /**
     * rename the old file
     */
    RetryingTransactionCallback<Void> renameOldFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME,
                    TEST_DIR + "\\" + FILE_OLD_TEMP);
            return null;
        }
    };
    tran.doInTransaction(renameOldFileCB, false, true);

    RetryingTransactionCallback<Void> validateOldFileGoneCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            try {
                driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NAME);
            } catch (IOException e) {
                // expect to go here since previous step renamed the file.
            }

            return null;
        }
    };
    tran.doInTransaction(validateOldFileGoneCB, false, true);

    logger.debug("Shuffle step next");
    /**
     * Move the new file into place, stuff should get shuffled
     */
    RetryingTransactionCallback<Void> moveNewFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.renameFile(testSession, testConnection, TEST_DIR + "\\" + FILE_NEW_TEMP,
                    TEST_DIR + "\\" + FILE_NAME);
            return null;
        }
    };

    tran.doInTransaction(moveNewFileCB, false, true);
    logger.debug("end of shuffle step");

    RetryingTransactionCallback<Void> validateCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            NodeRef shuffledNodeRef = getNodeForPath(testConnection, TEST_DIR + "\\" + FILE_NAME);

            Map<QName, Serializable> props = nodeService.getProperties(shuffledNodeRef);

            // Check trx:enabled has been shuffled.
            assertTrue("node does not contain shuffled ENABLED property",
                    props.containsKey(TransferModel.PROP_ENABLED));
            // check my residual MLText has been transferred
            assertTrue(props.containsKey(RESIDUAL_MTTEXT));

            // Check the titled aspect is correct
            assertEquals("name wrong", FILE_NAME,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_NAME));
            assertEquals("title wrong", FILE_TITLE,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_TITLE));
            assertEquals("description wrong", FILE_DESCRIPTION,
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_DESCRIPTION));

            // ALF-7641 - CIFS shuffle, does not preseve MLText values.
            Map<QName, Serializable> mlProps = mlAwareNodeService.getProperties(shuffledNodeRef);

            MLText multi = (MLText) mlAwareNodeService.getProperty(shuffledNodeRef, RESIDUAL_MTTEXT);
            assertTrue("MLText has lost values", multi.getValues().size() > 2);

            //               // ALF-7635 check auditable properties 
            assertEquals("creation date not preserved",
                    ((java.util.Date) testContext.testCreatedDate).getTime(),
                    ((java.util.Date) nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_CREATED))
                            .getTime());

            // ALF-7628 - preserve addressee and classifiable
            assertEquals("ADDRESSEE PROPERTY Not copied", "Fred",
                    nodeService.getProperty(shuffledNodeRef, ContentModel.PROP_ADDRESSEE));
            assertTrue("CLASSIFIABLE aspect not present",
                    nodeService.hasAspect(shuffledNodeRef, ContentModel.ASPECT_CLASSIFIABLE));

            // ALF-7584 - preserve node ref.
            assertEquals("noderef changed", testContext.testNodeRef, shuffledNodeRef);
            return null;
        }
    };

    tran.doInTransaction(validateCB, true, true);

    /**
     * Clean up just in case garbage is left from a previous run
     */
    RetryingTransactionCallback<Void> deleteOldFileCB = new RetryingTransactionCallback<Void>() {

        @Override
        public Void execute() throws Throwable {
            driver.deleteFile(testSession, testConnection, TEST_DIR + "\\" + FILE_OLD_TEMP);
            return null;
        }
    };

    tran.doInTransaction(deleteOldFileCB, false, true);

}

From source file:org.filteredpush.qc.date.DateUtils.java

/**
 * Given a string that may represent a date or range of dates, or date time or range of date times,
 * attempt to extract a standard date from that string.
 * /*from  www.j a  v  a2  s. c  o  m*/
 * @param verbatimEventDate a string containing a verbatim event date.
 * @param yearsBeforeSuspect  Dates that parse to a year prior to this year are marked as suspect.
 * @param assumemmddyyyy if true, assume that dates in the form nn-nn-nnnn are mm-dd-yyyy, if false, assume 
 *       that these are dd-mm-yyyy, if null, such dates are tested for ambiguity.  
 * 
 * @return an EventResult with a resultState for the nature of the match and result for the resulting date. 
 */
public static EventResult extractDateFromVerbatimER(String verbatimEventDate, int yearsBeforeSuspect,
        Boolean assumemmddyyyy) {
    EventResult result = new EventResult();
    String resultDate = null;

    // Remove some common no data comments
    if (verbatimEventDate != null && verbatimEventDate.contains("[no date]")) {
        verbatimEventDate = verbatimEventDate.replace("[no date]", "");
    }
    if (verbatimEventDate != null && verbatimEventDate.contains("[no year]")) {
        verbatimEventDate = verbatimEventDate.replace("[no year]", "");
    }

    // Strip off leading and trailing []
    if (verbatimEventDate != null && verbatimEventDate.startsWith("[") && verbatimEventDate.endsWith("]")) {
        verbatimEventDate = verbatimEventDate.substring(1);
        verbatimEventDate = verbatimEventDate.substring(0, verbatimEventDate.length() - 1);
    }

    if (verbatimEventDate != null && verbatimEventDate.matches(".*\\[[0-9]+\\].*")) {
        verbatimEventDate = verbatimEventDate.replace("[", "").replace("]", "");
    }

    // Strip off leading and trailing quotation marks
    if (verbatimEventDate != null && verbatimEventDate.startsWith("\"") && verbatimEventDate != null
            && verbatimEventDate.endsWith("\"")) {
        verbatimEventDate = verbatimEventDate.substring(1, verbatimEventDate.length() - 1);
    }

    // strip off leading and trailing whitespace
    if (verbatimEventDate != null && (verbatimEventDate.startsWith(" ") || verbatimEventDate.endsWith(" "))) {
        verbatimEventDate = verbatimEventDate.trim();
    }
    // strip off trailing period after number
    if (verbatimEventDate != null && verbatimEventDate.endsWith(".")
            && verbatimEventDate.matches(".*[0-9]\\.$")) {
        verbatimEventDate = verbatimEventDate.substring(0, verbatimEventDate.length() - 1);
        logger.debug(verbatimEventDate);
    }

    // Stop before doing work if provided verbatim string is null.
    if (isEmpty(verbatimEventDate)) {
        return result;
    }

    if (verbatimEventDate.matches("^[0-9]{4}[-][0-9]{2}[-][0-9]{2}/[0-9]{4}[-][0-9]{2}[-][0-9]{2}$")) {
        // if verbatim date is a ISO formatted range with identical first and last dates (/), use just one.
        // Example: 1982-12-11/1982-12-11  changed to 1982-12-11
        String[] bits = verbatimEventDate.split("/");
        if (bits.length == 2 && bits[0].equals(bits[1])) {
            verbatimEventDate = bits[0];
        }
    }
    if (verbatimEventDate.matches("^[0-9]{4}[/][0-9]{2}[/][0-9]{2}-[0-9]{4}[/][0-9]{2}[/][0-9]{2}$")) {
        // if verbatim date is a range with identical first and last dates (-), use just one.
        // Example: 1982/12/11-1982/12/11  changed to 1982/12/11
        String[] bits = verbatimEventDate.split("-");
        if (bits.length == 2 && bits[0].equals(bits[1])) {
            verbatimEventDate = bits[0];
        }
    }
    if (verbatimEventDate
            .matches("^[0-9]{1,2}[-. ][0-9]{1,2}[-. ][0-9]{4}/[0-9]{1,2}[-. ][0-9]{1,2}[-. ][0-9]{4}$")) {
        // if verbatim date is a range with identical first and last dates (/), use just one.
        // Example: 12-11-1982/12-11-1982  changed to 12-11-1982
        String[] bits = verbatimEventDate.split("/");
        if (bits.length == 2 && bits[0].equals(bits[1])) {
            verbatimEventDate = bits[0];
        }
    }
    if (verbatimEventDate
            .matches("^[0-9]{1,2}[./ ][0-9]{1,2}[./ ][0-9]{4}[-][0-9]{1,2}[./ ][0-9]{1,2}[./ ][0-9]{4}$")) {
        // if verbatim date is a range with identical first and last dates (-), use just one.
        // Example: 12/11/1982-12/11/1982  changed to 12/11/1982
        String[] bits = verbatimEventDate.split("-");
        if (bits.length == 2 && bits[0].equals(bits[1])) {
            verbatimEventDate = bits[0];
        }
    }
    if (verbatimEventDate.matches("^[0-9]{4}[-]([0-9]{1,2}|[A-Za-z]+)[-][0-9]{1,2}.*")) {
        // Both separators are the same.
        // Example 1982-02-05
        // Example 1982-Feb-05
        // Example 1982-02-05
        // Example 1982-02-05T05:03:06
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy/MM/dd").getParser(),
                    DateTimeFormat.forPattern("yyyy/MMM/dd").getParser(),
                    DateTimeFormat.forPattern("yyyy-MMM-dd").getParser(),
                    ISODateTimeFormat.dateOptionalTimeParser().getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            DateMidnight parseDate = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM-dd");
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (verbatimEventDate.matches("^[0-9]{4}[/]([0-9]{1,2}|[A-Za-z]+)[/][0-9]{1,2}.*")) {
        // Both separators are the same.
        // Example 1982/02/05
        // Example 1982/Feb/05
        // Example 1982-02-05
        // Example 1982/02/05T05:03:06
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy/MM/dd").getParser(),
                    DateTimeFormat.forPattern("yyyy/MMM/dd").getParser(),
                    DateTimeFormat.forPattern("yyyy-MMM-dd").getParser(),
                    ISODateTimeFormat.dateOptionalTimeParser().getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            DateMidnight parseDate = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM-dd");
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (verbatimEventDate.matches("^[0-9]{4}[.,][0-9]{1,2}[.,][0-9]{1,2}$")) {
        // Example 1982.02.05
        // Example 1982,02,05
        // Cases where the 1-2 digit numbers are both smaller than 12 are treated as ambiguous.
        String resultDateMD = null;
        String resultDateDM = null;
        DateMidnight parseDate1 = null;
        DateMidnight parseDate2 = null;
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy.MM.dd").getParser(),
                    DateTimeFormat.forPattern("yyyy,MM,dd").getParser(),
                    DateTimeFormat.forPattern("yyyy,MM.dd").getParser(),
                    DateTimeFormat.forPattern("yyyy.MM,dd").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            parseDate1 = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
            resultDateMD = parseDate1.toString("yyyy-MM-dd");
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy.dd.MM").getParser(),
                    DateTimeFormat.forPattern("yyyy,dd,MM").getParser(),
                    DateTimeFormat.forPattern("yyyy,dd.MM").getParser(),
                    DateTimeFormat.forPattern("yyyy.dd,MM").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            parseDate2 = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
            resultDateDM = parseDate2.toString("yyyy-MM-dd");
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
        if (resultDateMD != null && resultDateDM == null) {
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDateMD);
        } else if (resultDateMD == null && resultDateDM != null) {
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDateDM);
        } else if (resultDateMD != null && resultDateDM != null) {
            if (resultDateMD.equals(resultDateDM)) {
                result.setResultState(EventResult.EventQCResultState.DATE);
                result.setResult(resultDateDM);
            } else {
                result.setResultState(EventResult.EventQCResultState.AMBIGUOUS);
                Interval range = null;
                if (parseDate1.isBefore(parseDate2)) {
                    result.setResult(resultDateMD + "/" + resultDateDM);
                } else {
                    result.setResult(resultDateDM + "/" + resultDateMD);
                }
            }
        }

    }
    if (verbatimEventDate.matches("^[0-9]{1,2}[-/ ][0-9]{4}")) {
        // Example 02/1982
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("MM-yyyy").getParser(),
                    DateTimeFormat.forPattern("MM/yyyy").getParser(),
                    DateTimeFormat.forPattern("MM yyyy").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            DateMidnight parseDate = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (verbatimEventDate.matches("^[0-9]{4}[0-9]{1,2}[0-9]{1,2}[?]$")) {
        // Example: 19720325
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyyMMdd").getParser(),
                    DateTimeFormat.forPattern("yyyyMMdd?").getParser(),
                    ISODateTimeFormat.dateOptionalTimeParser().getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter()
                    .withLocale(Locale.CHINESE);
            DateMidnight parseDate = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM-dd");
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (verbatimEventDate.matches("^[0-9]{4}[-][0-9]{3}/[0-9]{4}[-][0-9]{3}$")) {
        // Example: 1982-145
        try {
            String[] bits = verbatimEventDate.split("/");
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy-D").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            LocalDate parseStartDate = LocalDate.parse(bits[0], formatter);
            LocalDate parseEndDate = LocalDate.parse(bits[1], formatter);
            resultDate = parseStartDate.toString("yyyy-MM-dd") + "/" + parseEndDate.toString("yyyy-MM-dd");
            logger.debug(resultDate);
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[0-9]{4}0000$")) {
        // case 19800000
        verbatimEventDate = verbatimEventDate.substring(0, 4);
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[0-9]{4}$")) {
        // Example: 1962 
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy").getParser(), };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            DateMidnight parseDate = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
            resultDate = parseDate.toString("yyyy");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[12][0-9]{1}00[']{0,1}s$")) {
        // Example: 1900s 
        try {
            String verbatimEventDateDelta = verbatimEventDate.replace("'s", "s");
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy's").getParser(), };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            DateMidnight parseDate = LocalDate.parse(verbatimEventDateDelta, formatter).toDateMidnight();
            DateMidnight endDate = parseDate.plusYears(100).minusDays(1);
            resultDate = parseDate.toString("yyyy") + "-01-01/" + endDate.toString("yyyy") + "-12-31";
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[12][0-9]{2}0[']{0,1}s$")) {
        // Example: 1970s 
        try {
            String verbatimEventDateDelta = verbatimEventDate.replace("'s", "s");
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy's").getParser(), };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            DateMidnight parseDate = LocalDate.parse(verbatimEventDateDelta, formatter).toDateMidnight();
            DateMidnight endDate = parseDate.plusYears(10).minusDays(1);
            resultDate = parseDate.toString("yyyy") + "-01-01/" + endDate.toString("yyyy") + "-12-31";
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[A-Za-z]{3,9}[.]{0,1}[ ]{0,1}[-/ ][0-9]{4}$")) {
        // Example: Jan-1980
        // Example: Jan./1980
        // Example: January 1980
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("MMM-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM/yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM /yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM yyyy").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            String cleaned = verbatimEventDate.replace(".", "");
            DateMidnight parseDate = LocalDate.parse(cleaned, formatter).toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        // Example: 04/03/1994  (ambiguous)
        // Example: 04/20/1994
        // Example: 20/04/1994
        String resultDateMD = null;
        String resultDateDM = null;
        DateMidnight parseDate1 = null;
        DateMidnight parseDate2 = null;
        if (assumemmddyyyy == null || assumemmddyyyy) {
            try {
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("MM/dd/yyyy").getParser(),
                        DateTimeFormat.forPattern("MM/dd yyyy").getParser(),
                        DateTimeFormat.forPattern("MM/dd-yyyy").getParser(),
                        DateTimeFormat.forPattern("MM/dd, yyyy").getParser(),
                        DateTimeFormat.forPattern("MM/dd,yyyy").getParser(),
                        DateTimeFormat.forPattern("MM dd yyyy").getParser(),
                        DateTimeFormat.forPattern("MM-dd-yyyy").getParser(),
                        DateTimeFormat.forPattern("MM.dd.yyyy").getParser(),
                        DateTimeFormat.forPattern("MM. dd. yyyy").getParser(),
                        DateTimeFormat.forPattern("MM. dd. yyyy.").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                parseDate1 = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
                resultDateMD = parseDate1.toString("yyyy-MM-dd");
            } catch (Exception e) {
                logger.debug(e.getMessage());
            }
        }
        if (assumemmddyyyy == null || !assumemmddyyyy) {
            try {
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("dd/MM/yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MM yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MM-yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MM, yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MM,yyyy").getParser(),
                        DateTimeFormat.forPattern("dd MM yyyy").getParser(),
                        DateTimeFormat.forPattern("dd-MM-yyyy").getParser(),
                        DateTimeFormat.forPattern("dd.MM.yyyy").getParser(),
                        DateTimeFormat.forPattern("dd. MM. yyyy").getParser(),
                        DateTimeFormat.forPattern("dd. MM. yyyy.").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                parseDate2 = LocalDate.parse(verbatimEventDate, formatter).toDateMidnight();
                resultDateDM = parseDate2.toString("yyyy-MM-dd");
            } catch (Exception e) {
                logger.debug(e.getMessage());
            }
        }
        if (resultDateMD != null && resultDateDM == null) {
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDateMD);
        } else if (resultDateMD == null && resultDateDM != null) {
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDateDM);
        } else if (resultDateMD != null && resultDateDM != null) {
            if (resultDateMD.equals(resultDateDM)) {
                result.setResultState(EventResult.EventQCResultState.DATE);
                result.setResult(resultDateDM);
            } else {
                result.setResultState(EventResult.EventQCResultState.AMBIGUOUS);
                Interval range = null;
                if (parseDate1.isBefore(parseDate2)) {
                    result.setResult(resultDateMD + "/" + resultDateDM);
                } else {
                    result.setResult(resultDateDM + "/" + resultDateMD);
                }
            }
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^([0-9]{1,2}|[A-Za-z]+)[-/.]([0-9]{1,2}|[A-Za-z]+)[-/. ][0-9]{4}$")) {
        // Example: 03/Jan/1982
        // Example: Jan-03-1982
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("MMM/dd/yyyy").getParser(),
                    DateTimeFormat.forPattern("dd/MMM/yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM/dd yyyy").getParser(),
                    DateTimeFormat.forPattern("dd/MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM-dd-yyyy").getParser(),
                    DateTimeFormat.forPattern("dd-MMM-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM-dd yyyy").getParser(),
                    DateTimeFormat.forPattern("dd-MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd.yyyy").getParser(),
                    DateTimeFormat.forPattern("dd.MMM.yyyy").getParser(),
                    DateTimeFormat.forPattern("MM.dd.yyyy").getParser(),
                    DateTimeFormat.forPattern("dd.MM.yyyy").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();

            DateMidnight parseDate = LocalDate.parse(verbatimEventDate, formatter.withLocale(Locale.ENGLISH))
                    .toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM-dd");
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[X*]{2}[-/. ]([0-9]{1,2}|[A-Za-z]+)[-/. ][0-9]{4}$")) {
        // Example: XX-04-1982   (XX for day)
        // Example: XX-Jan-1995
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("MMM/yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.yyyy").getParser(),
                    DateTimeFormat.forPattern("MM.yyyy").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();

            DateMidnight parseDate = LocalDate
                    .parse(verbatimEventDate.substring(3), formatter.withLocale(Locale.ENGLISH))
                    .toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[X*]{2}[-/. ][X*]{2,3}[-/. ][0-9]{4}$")) {
        // Example: XX-XXX-1995
        // Example: **-**-1995
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy").getParser(), };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            String yearBit = verbatimEventDate.substring(verbatimEventDate.length() - 4);
            DateMidnight parseDate = LocalDate.parse(yearBit, formatter.withLocale(Locale.ENGLISH))
                    .toDateMidnight();
            resultDate = parseDate.toString("yyyy");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (verbatimEventDate.matches("^[0-9]{4}[-][0-9]{3}$")) {
        // Example: 1994-128  (three digits after year = day of year).
        if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
            try {
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy-D").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                LocalDate parseDate = LocalDate.parse(verbatimEventDate, formatter);
                resultDate = parseDate.toString("yyyy-MM-dd");
                logger.debug(resultDate);
                result.setResultState(EventResult.EventQCResultState.DATE);
                result.setResult(resultDate);
            } catch (Exception e) {
                logger.debug(e.getMessage());
            }

        }
    }

    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        try {
            // Example: 1983-15  (two digits after year may fall into subsequent blocks).
            // Example: 1933-Mar
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy/M").getParser(),
                    DateTimeFormat.forPattern("yyyy-M").getParser(),
                    DateTimeFormat.forPattern("yyyy-MMM").getParser(),
                    DateTimeFormat.forPattern("yyyy.MMM").getParser(),
                    DateTimeFormat.forPattern("yyyy.MMM.").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM.").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM").getParser(),
                    DateTimeFormat.forPattern("yyyy. MMM.").getParser(),
                    DateTimeFormat.forPattern("yyyy. MMM").getParser(),
                    DateTimeFormat.forPattern("yyyy/MMM").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            String cleaned = cleanMonth(verbatimEventDate);
            LocalDate parseDate = LocalDate.parse(cleaned, formatter.withLocale(Locale.ENGLISH));
            resultDate = parseDate.toString("yyyy-MM");
            // resultDate =  parseDate.dayOfMonth().withMinimumValue() + "/" + parseDate.dayOfMonth().withMaximumValue();
            logger.debug(resultDate);
            if (verbatimEventDate.matches("^[0-9]{4}[-][0-9]{2}$")) {
                String century = verbatimEventDate.substring(0, 2);
                String startBit = verbatimEventDate.substring(0, 4);
                String endBit = verbatimEventDate.substring(5, 7);
                // 1815-16  won't parse here, passes to next block
                // 1805-06  could be month or abbreviated year
                // 1805-03  should to be month
                if (Integer.parseInt(startBit) >= Integer.parseInt(century + endBit)) {
                    result.setResultState(EventResult.EventQCResultState.RANGE);
                    result.setResult(resultDate);
                } else {
                    result.setResultState(EventResult.EventQCResultState.SUSPECT);
                    result.setResult(resultDate);
                }
            } else {
                result.setResultState(EventResult.EventQCResultState.RANGE);
                result.setResult(resultDate);
            }
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[0-9]{4}[-][0-9]{2}$")) {
        // Example: 1884-85   (two digits look like year later in century).
        try {
            String century = verbatimEventDate.substring(0, 2);
            String startBit = verbatimEventDate.substring(0, 4);
            String endBit = verbatimEventDate.substring(5, 7);
            String assembly = startBit + "/" + century + endBit;
            logger.debug(assembly);
            Interval parseDate = Interval.parse(assembly);
            logger.debug(parseDate);
            resultDate = parseDate.getStart().toString("yyyy") + "/" + parseDate.getEnd().toString("yyyy");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[0-9]{4}[0-9]{2}[0-9]{2}$") && !verbatimEventDate.endsWith("0000")) {
        // Example: 19950315
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyyMMdd").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            DateMidnight parseDate = LocalDate.parse(verbatimEventDate, formatter.withLocale(Locale.ENGLISH))
                    .toDateMidnight();
            resultDate = parseDate.toString("yyyy-MM-dd");
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        // Example: 1845 
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            LocalDate parseDate = LocalDate.parse(verbatimEventDate, formatter);
            resultDate = parseDate.dayOfYear().withMinimumValue() + "/"
                    + parseDate.dayOfYear().withMaximumValue();
            logger.debug(resultDate);
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        // Multiple yyyy-mmm-ddd, mmm-dd-yyyy, dd-mmm-yyyy patterns.
        try {
            DateTimeParser[] parsers = { DateTimeFormat.forPattern("yyyy MMM dd").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM. dd").getParser(),
                    DateTimeFormat.forPattern("yyyy, MMM dd").getParser(),
                    DateTimeFormat.forPattern("yyyy, MMM. dd").getParser(),
                    DateTimeFormat.forPattern("yyyy.MMM.dd").getParser(),
                    DateTimeFormat.forPattern("yyyy.MMM.dd.").getParser(),
                    DateTimeFormat.forPattern("yyyy. MMM. dd").getParser(),
                    DateTimeFormat.forPattern("yyyy. MMM. dd.").getParser(),
                    DateTimeFormat.forPattern("yyyy. MMM dd.").getParser(),
                    DateTimeFormat.forPattern("yyyy. MMM dd").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM. dd.").getParser(),
                    DateTimeFormat.forPattern("yyyy: MMM. dd.").getParser(),
                    DateTimeFormat.forPattern("yyyy: MMM. dd").getParser(),
                    DateTimeFormat.forPattern("yyyy: MMM dd").getParser(),
                    DateTimeFormat.forPattern("yyyy:MMM dd").getParser(),
                    DateTimeFormat.forPattern("yyyy:MMM. dd").getParser(),
                    DateTimeFormat.forPattern("yyyy:MMM.dd").getParser(),

                    DateTimeFormat.forPattern("yyyy MMM dd'st'").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM. dd'st'").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM dd'nd'").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM. dd'nd'").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM dd'rd'").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM. dd'rd'").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM dd'th'").getParser(),
                    DateTimeFormat.forPattern("yyyy MMM. dd'th'").getParser(),

                    DateTimeFormat.forPattern("MMM dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd., yyyy").getParser(),
                    DateTimeFormat.forPattern("MMMdd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'st', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'nd', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'rd', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'd', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'th', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'st', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'nd', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'rd', yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'th', yyyy").getParser(),

                    DateTimeFormat.forPattern("MMM.dd,yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'st',yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'nd',yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'rd',yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'd',yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'th',yyyy").getParser(),

                    DateTimeFormat.forPattern("MMM.dd.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'st'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'nd'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'rd'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'd'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd'th'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'st'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'nd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'rd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'th'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'st'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'nd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'rd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'th'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'st'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'nd'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'rd'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'd'.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'th'.yyyy").getParser(),

                    DateTimeFormat.forPattern("MMM-dd-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM-dd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM-dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd-MMM-yyyy").getParser(),
                    DateTimeFormat.forPattern("dd.MMM.yyyy").getParser(),
                    DateTimeFormat.forPattern("dd,MMM,yyyy").getParser(),
                    DateTimeFormat.forPattern("dd.MMM.,yyyy").getParser(),
                    DateTimeFormat.forPattern("dd. MMM.,yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM, dd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM, dd. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM, dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM, dd., yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd/yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd,yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd,yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd., yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM., dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.,dd, yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'' yyyy").getParser(),
                    DateTimeFormat.forPattern("dd. MMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd. MMM.yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM., yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM.,yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM,.yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM,. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM..yyyy").getParser(),

                    DateTimeFormat.forPattern("dd MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM,yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM.yyyy").getParser(),
                    DateTimeFormat.forPattern("ddMMM.yyyy").getParser(),
                    DateTimeFormat.forPattern("ddMMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd.MMM-yyyy").getParser(),
                    DateTimeFormat.forPattern("dd-MMM-yyyy").getParser(),
                    DateTimeFormat.forPattern("dd.MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd. MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd, MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd, MMM; yyyy").getParser(),
                    DateTimeFormat.forPattern("dd. MMM; yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM-yyyy").getParser(),
                    DateTimeFormat.forPattern("dd-MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("ddMMMyyyy").getParser(),

                    DateTimeFormat.forPattern("MMM dd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd/yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'st' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'nd' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'rd' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'd' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'th' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'st' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'nd' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'rd' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'd' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'th' yyyy").getParser(),
                    DateTimeFormat.forPattern("MMMdd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM.dd yyyy").getParser(),

                    DateTimeFormat.forPattern("dd MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'st' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'nd' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'rd' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'd' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'th MMM', yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM., yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'st' MMM., yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'nd' MMM., yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'rd' MMM., yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'th' MMM., yyyy").getParser(),

                    DateTimeFormat.forPattern("dd MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'st' MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'nd' MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'rd' MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'd' MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'th' MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("dd MMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'st' MMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'nd' MMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'rd' MMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'd' MMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'th' MMM. yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'st' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'nd' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'rd' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'd' MMM, yyyy").getParser(),
                    DateTimeFormat.forPattern("dd'th' MMM, yyyy").getParser(),

                    DateTimeFormat.forPattern("dd/MMM/yyyy").getParser(),
                    DateTimeFormat.forPattern("dd/MMM yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM/dd yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM/dd/yyyy").getParser(),

                    DateTimeFormat.forPattern("MMM dd. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'st'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'nd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'rd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'th'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'st'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'nd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'rd'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'th'. yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd.yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd.yyyy").getParser(),

                    DateTimeFormat.forPattern("MMM. dd-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'st'-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'nd'-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'rd'-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM. dd'th'-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'st'-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'nd'-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'rd'-yyyy").getParser(),
                    DateTimeFormat.forPattern("MMM dd'th'-yyyy").getParser(),

                    DateTimeFormat.forPattern("yyyy-MMM-dd").getParser() };
            DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers).toFormatter();
            String cleaned = cleanMonth(verbatimEventDate);
            cleaned = cleaned.replace("''", "'");
            try {
                // Specify English locale, or local default will be used
                LocalDate parseDate = LocalDate.parse(cleaned, formatter.withLocale(Locale.ENGLISH));
                resultDate = parseDate.toString("yyyy-MM-dd");
            } catch (Exception e) {
                try {
                    logger.debug(e.getMessage());
                    LocalDate parseDate = LocalDate.parse(cleaned, formatter.withLocale(Locale.FRENCH));
                    resultDate = parseDate.toString("yyyy-MM-dd");
                } catch (Exception e1) {
                    try {
                        logger.debug(e1.getMessage());
                        LocalDate parseDate = LocalDate.parse(cleaned, formatter.withLocale(Locale.ITALIAN));
                        resultDate = parseDate.toString("yyyy-MM-dd");
                    } catch (Exception e2) {
                        try {
                            logger.debug(e2.getMessage());
                            LocalDate parseDate = LocalDate.parse(cleaned, formatter.withLocale(Locale.GERMAN));
                            resultDate = parseDate.toString("yyyy-MM-dd");
                        } catch (Exception e3) {
                            try {
                                logger.debug(e2.getMessage());
                                LocalDate parseDate = LocalDate.parse(cleaned,
                                        formatter.withLocale(Locale.forLanguageTag("es")));
                                resultDate = parseDate.toString("yyyy-MM-dd");
                            } catch (Exception e4) {
                                logger.debug(e2.getMessage());
                                LocalDate parseDate = LocalDate.parse(cleaned,
                                        formatter.withLocale(Locale.forLanguageTag("pt")));
                                resultDate = parseDate.toString("yyyy-MM-dd");
                            }
                        }
                    }
                }
            }
            logger.debug(resultDate);
            result.setResultState(EventResult.EventQCResultState.DATE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    logger.debug(result.getResultState());
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        // Example: jan.-1992
        // Example: January 1992
        if (verbatimEventDate.matches(".*[0-9]{4}.*")) {
            try {
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("MMM, yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM., yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM.,yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM.-yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM.yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM. yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM-yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM -yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM/yyyy").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                String cleaned = cleanMonth(verbatimEventDate);
                // Strip off a trailing period after a final year
                if (cleaned.matches("^.*[0-9]{4}[.]$")) {
                    cleaned = cleaned.replaceAll("[.]$", "");
                }
                LocalDate parseDate = LocalDate.parse(cleaned, formatter.withLocale(Locale.ENGLISH));
                resultDate = parseDate.toString("yyyy-MM");
                logger.debug(resultDate);
                result.setResultState(EventResult.EventQCResultState.RANGE);
                result.setResult(resultDate);
            } catch (Exception e) {
                logger.debug(e.getMessage());
            }
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[0-9]{4}([- ]+| to |[/ ]+)[0-9]{4}$")) {
        // Example:  1882-1995
        // Example:  1882 to 1885
        // Example:  1882/1885
        try {
            String cleaned = verbatimEventDate.replace(" ", "");
            cleaned = cleaned.replace("-", "/");
            if (cleaned.matches("^[0-9]{4}to[0-9]{4}$")) {
                int len = verbatimEventDate.length();
                int lastYear = len - 4;
                cleaned = verbatimEventDate.substring(0, 4) + "/" + verbatimEventDate.substring(lastYear, len);
            }
            logger.debug(cleaned);
            Interval parseDate = Interval.parse(cleaned);
            logger.debug(parseDate);
            resultDate = parseDate.getStart().toString("yyyy") + "/" + parseDate.getEnd().toString("yyyy");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN) && verbatimEventDate
            .matches("^[A-Za-z]+[.]{0,1}( and | to |[-][ ]{0,1}| [-] )[A-Za-z]+[.]{0,1}(, |[/ .])[0-9]{4}$")) {
        logger.debug(verbatimEventDate);
        // Example: Jan to Feb 1882
        // Example: Jan-Feb/1882
        verbatimEventDate = verbatimEventDate.replace(", ", " ");
        if (verbatimEventDate.matches("^[A-Za-z]+[.]{0,1}[-][A-Za-z]+[.]{0,1}[.][0-9]{4}$")) {
            // transform case with multiple periods to slash before year.
            verbatimEventDate = verbatimEventDate.substring(0, verbatimEventDate.length() - 5) + "/"
                    + verbatimEventDate.substring(verbatimEventDate.length() - 4);
            logger.debug(verbatimEventDate);
        }
        if (verbatimEventDate.matches("^[A-Za-z]+[.]{0,1}[ ][-][ ]{1}[A-Za-z]+[.]{0,1}[/ .][0-9]{4}$")) {
            // remove space around dash.
            verbatimEventDate = verbatimEventDate.replace(" - ", "-");
            logger.debug(verbatimEventDate);
        }
        if (verbatimEventDate.matches("^[A-Za-z]+[.]{0,1}[-][ ]{1}[A-Za-z]+[.]{0,1}[/ .][0-9]{4}$")) {
            // remove space trailing after dash.
            verbatimEventDate = verbatimEventDate.replace("- ", "-");
            logger.debug(verbatimEventDate);
        }
        if (verbatimEventDate.matches("^[A-Za-z]+[.]{0,1} and {1}[A-Za-z]+[.]{0,1}[/ .][0-9]{4}$")) {
            // replace and with dash
            verbatimEventDate = verbatimEventDate.replace(" and ", "-");
            logger.debug(verbatimEventDate);
        }
        if (verbatimEventDate.matches("^[A-Za-z]+[.]{0,1} to {1}[A-Za-z]+[.]{0,1}[/ .][0-9]{4}$")) {
            // replace to with dash
            verbatimEventDate = verbatimEventDate.replace(" to ", "-");
            logger.debug(verbatimEventDate);
        }
        try {
            String[] bits = verbatimEventDate.replace(" ", "/").split("-");
            if (bits != null && bits.length == 2) {
                String year = verbatimEventDate.substring(verbatimEventDate.length() - 4,
                        verbatimEventDate.length());
                String startBit = bits[0] + "/" + year;
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("MMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM./yyyy").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                LocalDate parseStartDate = LocalDate.parse(cleanMonth(startBit),
                        formatter.withLocale(Locale.ENGLISH));
                LocalDate parseEndDate = LocalDate.parse(cleanMonth(bits[1]),
                        formatter.withLocale(Locale.ENGLISH));
                resultDate = parseStartDate.toString("yyyy-MM") + "/" + parseEndDate.toString("yyyy-MM");
                logger.debug(resultDate);
                result.setResultState(EventResult.EventQCResultState.RANGE);
                result.setResult(resultDate);
            }
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN) && verbatimEventDate.matches(
            "^[0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}( - |[-])[0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[/ -.][0-9]{4}$")) {
        logger.debug(verbatimEventDate);
        // Example: 05/Jan/1882-03/Feb/1885
        if (verbatimEventDate.matches(
                "^[0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[-][0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[-][0-9]{4}$")) {
            // transform case with multiple dashes to slash before year.
            verbatimEventDate = verbatimEventDate.substring(0, verbatimEventDate.length() - 5) + "/"
                    + verbatimEventDate.substring(verbatimEventDate.length() - 4);
            logger.debug(verbatimEventDate);
        }
        if (verbatimEventDate.matches(
                "^[0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[-][0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[.][0-9]{4}$")) {
            // transform case with multiple periods to slash before year.
            verbatimEventDate = verbatimEventDate.substring(0, verbatimEventDate.length() - 5) + "/"
                    + verbatimEventDate.substring(verbatimEventDate.length() - 4);
            logger.debug(verbatimEventDate);
        }
        try {
            String[] bits = verbatimEventDate.replace(" - ", "-").replace(" ", "/").split("-");
            if (bits != null && bits.length == 2) {
                String year = verbatimEventDate.substring(verbatimEventDate.length() - 4,
                        verbatimEventDate.length());
                String startBit = bits[0] + "/" + year;
                logger.debug(cleanMonth(startBit));
                logger.debug(cleanMonth(bits[1]));
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("dd MMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("dd.MMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("ddMMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("dd MMM./yyyy").getParser(),
                        DateTimeFormat.forPattern("dd.MMM./yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MMM./yyyy").getParser(),
                        DateTimeFormat.forPattern("ddMMM./yyyy").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                LocalDate parseStartDate = LocalDate.parse(cleanMonth(startBit),
                        formatter.withLocale(Locale.ENGLISH));
                LocalDate parseEndDate = LocalDate.parse(cleanMonth(bits[1]),
                        formatter.withLocale(Locale.ENGLISH));
                resultDate = parseStartDate.toString("yyyy-MM-dd") + "/" + parseEndDate.toString("yyyy-MM-dd");
                logger.debug(resultDate);
                result.setResultState(EventResult.EventQCResultState.RANGE);
                result.setResult(resultDate);
            }
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN) && verbatimEventDate.matches(
            "^[A-Za-z]+[.]{0,1}[ ]{0,1}[0-9]{1,2}( - |[-]| to | and | et )[A-Za-z]+[.]{0,1}[ ]{0,1}[0-9]{1,2}[/ .,][ ]{0,1}[0-9]{4}$")) {
        logger.debug(verbatimEventDate);
        // Example: Aug. 5 - Sept. 8, 1943
        try {
            String[] bits = verbatimEventDate.replace(" to ", "-").replace(" - ", "-").replace(" and ", "-")
                    .replace(" et ", "-").replace(", ", " ").replace(" ", "/").split("-");
            if (bits != null && bits.length == 2) {
                String year = verbatimEventDate.substring(verbatimEventDate.length() - 4,
                        verbatimEventDate.length());
                String startBit = bits[0] + "/" + year;
                logger.debug(cleanMonth(startBit));
                logger.debug(cleanMonth(bits[1]));
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("MMM/dd/yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM./dd/yyyy").getParser(),
                        DateTimeFormat.forPattern("MMM.dd/yyyy").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                LocalDate parseStartDate = LocalDate.parse(cleanMonth(startBit),
                        formatter.withLocale(Locale.ENGLISH));
                LocalDate parseEndDate = LocalDate.parse(cleanMonth(bits[1]),
                        formatter.withLocale(Locale.ENGLISH));
                resultDate = parseStartDate.toString("yyyy-MM-dd") + "/" + parseEndDate.toString("yyyy-MM-dd");
                logger.debug(resultDate);
                result.setResultState(EventResult.EventQCResultState.RANGE);
                result.setResult(resultDate);
            }
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN) && verbatimEventDate.matches(
            "^[0-9]{1,2}([ ]{0,1}[-][ ]{0,1}| and | et | to )[0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[/ -.][0-9]{4}$")) {
        // Example: 11 et 14 VII 1910
        // Example: 05-02 Jan./1992
        String toCheck = verbatimEventDate;
        toCheck = toCheck.replace(" - ", "-").replace(" et ", "-").replace(" and ", "-").replace(" to ", "-");
        // Note: "and" has different semantics than "to", may imply that a specimen record
        // represents two occurrences (e.g. flower on one date, fruit on another) rather than
        // a range, but dwc:eventDate representation for both forms on one event is a range.
        if (toCheck.matches("^[0-9]{1,2}[-][0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[-][0-9]{4}$")) {
            // transform case with multiple dashes to slash before year.
            toCheck = toCheck.substring(0, toCheck.length() - 5) + "/"
                    + toCheck.substring(toCheck.length() - 4);
            logger.debug(toCheck);
        }
        if (toCheck.matches("^[0-9]{1,2}[-][0-9]{1,2}[ /.]{0,1}[A-Za-z]+[.]{0,1}[.][0-9]{4}$")) {
            // transform case with multiple periods to slash before year.
            toCheck = toCheck.substring(0, toCheck.length() - 5) + "/"
                    + toCheck.substring(toCheck.length() - 4);
            logger.debug(toCheck);
        }
        try {
            String[] bits = toCheck.replace(" ", "/").split("-");
            if (bits != null && bits.length == 2) {
                String year = toCheck.substring(toCheck.length() - 4, toCheck.length());
                logger.debug(cleanMonth(bits[1]));
                DateTimeParser[] parsers = { DateTimeFormat.forPattern("dd MMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("dd.MMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("ddMMM/yyyy").getParser(),
                        DateTimeFormat.forPattern("dd MMM./yyyy").getParser(),
                        DateTimeFormat.forPattern("dd.MMM./yyyy").getParser(),
                        DateTimeFormat.forPattern("dd/MMM./yyyy").getParser(),
                        DateTimeFormat.forPattern("ddMMM./yyyy").getParser() };
                DateTimeFormatter formatter = new DateTimeFormatterBuilder().append(null, parsers)
                        .toFormatter();
                LocalDate parseEndDate = LocalDate.parse(cleanMonth(bits[1]),
                        formatter.withLocale(Locale.ENGLISH));
                String startMonthYear = parseEndDate.toString("MMM/yyyy");
                String startBit = bits[0] + "/" + startMonthYear;
                logger.debug(startBit);
                LocalDate parseStartDate = LocalDate.parse(startBit, formatter.withLocale(Locale.ENGLISH));
                resultDate = parseStartDate.toString("yyyy-MM-dd") + "/" + parseEndDate.toString("yyyy-MM-dd");
                logger.debug(resultDate);
                result.setResultState(EventResult.EventQCResultState.RANGE);
                result.setResult(resultDate);
            }
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[0-9]{2}[-. ]XXX[-. ][0-9]{4}$")) {
        // Example: 05-XXX-1884
        try {
            String start = verbatimEventDate.substring(verbatimEventDate.length() - 4) + "-01-"
                    + verbatimEventDate.substring(0, 2);
            String end = verbatimEventDate.substring(verbatimEventDate.length() - 4) + "-12-"
                    + verbatimEventDate.substring(0, 2);
            EventResult compositeResult = DateUtils.extractDateFromVerbatimER(start + "/" + end,
                    yearsBeforeSuspect, assumemmddyyyy);
            logger.debug(compositeResult.getResultState());
            if (compositeResult.getResultState().equals(EventResult.EventQCResultState.RANGE)) {
                result.setResultState(EventResult.EventQCResultState.RANGE);
                result.setResult(compositeResult.getResult());
                logger.debug(result.getResult());
            }
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)
            && verbatimEventDate.matches("^[0-9]{4}-[0-9]{2}/[0-9]{4}-[0-9]{2}$")) {
        // Example: 1885-03/1886-04
        try {
            Interval parseDate = Interval.parse(verbatimEventDate);
            logger.debug(parseDate);
            resultDate = parseDate.getStart().toString("yyyy-MM") + "/"
                    + parseDate.getEnd().toString("yyyy-MM");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        // Example: 1995-03-05/1996-05-08
        try {
            Interval parseDate = Interval.parse(verbatimEventDate);
            logger.debug(parseDate);
            resultDate = parseDate.getStart().toString("yyyy-MM-dd") + "/"
                    + parseDate.getEnd().toString("yyyy-MM-dd");
            result.setResultState(EventResult.EventQCResultState.RANGE);
            result.setResult(resultDate);
        } catch (Exception e) {
            logger.debug(e.getMessage());
        }
    }
    if (result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        // Example: Jan,15-18 1882
        // Example: Jan. 17 and 18 1882
        String cleaned = verbatimEventDate.trim();
        if (verbatimEventDate.matches("^[A-Za-z.]+[ ,]+[0-9]{1,2} and [0-9]{0,2}[ ,]+[0-9]{4}$")) {
            // Note: "and" has different semantics than "to", may imply that a specimen record
            // represents two occurrences (e.g. flower on one date, fruit on another) rather than
            // a range, but dwc:eventDate representation for both forms on one event is a range.
            cleaned = cleaned.replace(" and ", " to ");
        }
        if (verbatimEventDate.matches("^[A-Za-z.]+[ ,]+[0-9]{1,2}-[0-9]{0,2}[ ,]+[0-9]{4}$")) {
            cleaned = cleaned.replace("-", " to ");
        }
        if (cleaned.contains(" to ")) {
            String[] bits = cleaned.split(" to ");
            String yearRegex = ".*([0-9]{4}).*";
            Matcher yearMatcher = Pattern.compile(yearRegex).matcher(cleaned);
            String monthRegex = "([A-Za-z.]+).*";
            Matcher monthMatcher = Pattern.compile(monthRegex).matcher(cleaned);
            if (yearMatcher.matches() && monthMatcher.matches()) {
                String year = yearMatcher.group(1);
                String month = monthMatcher.group(1);
                if (bits.length == 2) {
                    if (!bits[0].contains(year)) {
                        bits[0] = bits[0] + " " + year;
                    }
                    if (!bits[1].contains(year)) {
                        bits[1] = bits[1] + " " + year;
                    }
                    if (!bits[1].contains(month)) {
                        bits[1] = month + " " + bits[1];
                    }
                    Map<String, String> resultBit0 = DateUtils.extractDateFromVerbatim(bits[0]);
                    if (resultBit0.size() > 0 && resultBit0.get("resultState").equals("date")) {
                        Map<String, String> resultBit1 = DateUtils.extractDateFromVerbatim(bits[1]);
                        if (resultBit1.size() > 0 && resultBit1.get("resultState").equals("date")) {
                            result.setResultState(EventResult.EventQCResultState.RANGE);
                            result.setResult(resultBit0.get("result") + "/" + resultBit1.get("result"));
                        }
                    }
                    logger.debug(bits[0]);
                    logger.debug(bits[1]);
                }
            }
        }
    }

    // Now test to see if result is sane.
    if (result != null && !result.getResultState().equals(EventResult.EventQCResultState.NOT_RUN)) {
        Interval testExtract = DateUtils.extractDateInterval(result.getResult());
        if (testExtract == null || testExtract.getStart().getYear() < yearsBeforeSuspect) {
            result.setResultState(EventResult.EventQCResultState.SUSPECT);
            logger.debug(result.getResult());
            logger.debug(testExtract);
        } else {
            logger.debug(result.getResult());
        }
        if (!verbatimEventDate.matches(".*[0-9]{4}.*") && yearsBeforeSuspect > 999) {
            result = new EventResult();
            logger.debug(result.getResult());
        }
    }

    return result;
}

From source file:org.yccheok.jstock.gui.JStock.java

private void jRadioButtonMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonMenuItem1ActionPerformed
    if (false == org.yccheok.jstock.gui.Utils.hasSpecifiedLanguageFile(this.jStockOptions.getLocale())) {
        // User is currently using default langauge. English is our default
        // langauge. Hence, do nothing and return early. This is because we 
        // want to avoid from having the following locale.
        ///*from  w w  w  .j ava2s.  c o m*/
        // Locale(ENGLISH, FRANCE)
        //
        // This will yield incorrect behavior during currency formatting.
        // We prefer to have
        //
        // Locale(FRANCE, FRANCE)
        //
        // English language will be displayed still, as we do not have 
        // FRANCE language file yet.
        //
        return;
    }

    // Avoid from Confirm Dialog to pop up when user change to same language (i.e. english)
    if (false == this.jStockOptions.getLocale().getLanguage().equals(Locale.ENGLISH.getLanguage())) {
        // Do not suprise user with sudden restart. Ask for their permission to do so.
        final int result = JOptionPane.showConfirmDialog(this,
                MessagesBundle.getString("question_message_restart_now"),
                MessagesBundle.getString("question_title_restart_now"), JOptionPane.YES_NO_OPTION);
        if (result == JOptionPane.YES_OPTION) {
            final Locale locale = new Locale(Locale.ENGLISH.getLanguage(), Locale.getDefault().getCountry(),
                    Locale.getDefault().getVariant());
            this.jStockOptions.setLocale(locale);
            org.yccheok.jstock.gui.Utils.restartApplication(this);
        } // return to the previous selection if the user press "no" in the dialog
        else {
            if (Utils.isTraditionalChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem4.setSelected(true);
            } else if (Utils.isSimplifiedChinese(this.jStockOptions.getLocale())) {
                this.jRadioButtonMenuItem2.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.GERMAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem3.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.ITALIAN.getLanguage()) == 0) {
                this.jRadioButtonMenuItem5.setSelected(true);
            } else if (this.jStockOptions.getLocale().getLanguage()
                    .compareTo(Locale.FRENCH.getLanguage()) == 0) {
                this.jRadioButtonMenuItem6.setSelected(true);
            }
        }
    }
}