Example usage for java.util Locale ITALIAN

List of usage examples for java.util Locale ITALIAN

Introduction

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

Prototype

Locale ITALIAN

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

Click Source Link

Document

Useful constant for language.

Usage

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

/**
 * Initialize language menu items so that correct item is being selected
 * according to current default locale.//from  w  ww  . j  a  v  a  2  s .  c o  m
 */
private void initLanguageMenuItemsSelection() {
    // Please revise Statement's construct code, when adding in new language.
    // So that its language guessing algorithm will work as it is.

    final Locale defaultLocale = Locale.getDefault();
    if (Utils.isTraditionalChinese(defaultLocale)) {
        this.jRadioButtonMenuItem4.setSelected(true);
    } else if (Utils.isSimplifiedChinese(defaultLocale)) {
        this.jRadioButtonMenuItem2.setSelected(true);
    } else if (defaultLocale.getLanguage().equals(Locale.GERMAN.getLanguage())) {
        this.jRadioButtonMenuItem3.setSelected(true);
    } else if (defaultLocale.getLanguage().equals(Locale.ITALIAN.getLanguage())) {
        this.jRadioButtonMenuItem5.setSelected(true);
    } else {
        this.jRadioButtonMenuItem1.setSelected(true);
    }
}

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

/**
 * Initialize language menu items so that correct item is being selected
 * according to current default locale./*from  w w w  .  jav  a  2 s .  c  o m*/
 */
private void initLanguageMenuItemsSelection() {
    // Please revise Statement's construct code, when adding in new language.
    // So that its language guessing algorithm will work as it is.

    final Locale defaultLocale = Locale.getDefault();
    if (Utils.isTraditionalChinese(defaultLocale)) {
        this.jRadioButtonMenuItem4.setSelected(true);
    } else if (Utils.isSimplifiedChinese(defaultLocale)) {
        this.jRadioButtonMenuItem2.setSelected(true);
    } else if (defaultLocale.getLanguage().equals(Locale.GERMAN.getLanguage())) {
        this.jRadioButtonMenuItem3.setSelected(true);
    } else if (defaultLocale.getLanguage().equals(Locale.ITALIAN.getLanguage())) {
        this.jRadioButtonMenuItem5.setSelected(true);
    } else if (defaultLocale.getLanguage().equals(Locale.FRENCH.getLanguage())) {
        this.jRadioButtonMenuItem6.setSelected(true);
    } else {
        this.jRadioButtonMenuItem1.setSelected(true);
    }
}

From source file:org.openmrs.ObsTest.java

@Test
public void getValueAsString_shouldReturnLocalizedCodedConcept() throws Exception {
    ConceptDatatype cdt = new ConceptDatatype();
    cdt.setHl7Abbreviation("CWE");

    Concept cn = new Concept();
    cn.setDatatype(cdt);/*from ww w  .  j  ava 2 s.c o m*/
    cn.addName(new ConceptName(VERO, Locale.ITALIAN));

    Obs obs = new Obs();
    obs.setValueCoded(cn);
    obs.setConcept(cn);
    obs.setValueCodedName(new ConceptName("True", Locale.US));

    Assert.assertEquals(VERO, obs.getValueAsString(Locale.ITALIAN));
}

From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java

public void setUp() throws Exception {
    dialect = (Dialect) ctx.getBean("dialect");

    nodeService = (NodeService) ctx.getBean("dbNodeService");
    dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
    dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    luceneFTS = (FullTextSearchIndexer) ctx.getBean("LuceneFullTextSearchIndexer");
    contentService = (ContentService) ctx.getBean("contentService");
    queryRegisterComponent = (QueryRegisterComponent) ctx.getBean("queryRegisterComponent");
    namespacePrefixResolver = (DictionaryNamespaceComponent) ctx.getBean("namespaceService");
    transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug");
    indexerAndSearcher = (IndexerAndSearcher) ctx.getBean("admLuceneIndexerAndSearcherFactory");
    luceneConfig = (LuceneConfig) ctx.getBean("admLuceneIndexerAndSearcherFactory");
    ((LuceneConfig) indexerAndSearcher).setMaxAtomicTransformationTime(1000000);
    transactionService = (TransactionService) ctx.getBean("transactionComponent");
    retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper");
    tenantService = (TenantService) ctx.getBean("tenantService");
    queryEngine = (QueryEngine) ctx.getBean("adm.luceneQueryEngineImpl");

    nodeBulkLoader = (NodeBulkLoader) ctx.getBean("nodeDAO");

    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);

    namespaceDao = (NamespaceDAO) ctx.getBean("namespaceDAO");

    I18NUtil.setLocale(Locale.UK);

    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");

    queryRegisterComponent.loadQueryCollection("testQueryRegister.xml");

    assertEquals(true, ctx.isSingleton("LuceneFullTextSearchIndexer"));

    testTX = transactionService.getUserTransaction();
    testTX.begin();/*  w  w  w  .ja  va2  s .c  o m*/
    this.authenticationComponent.setSystemUserAsCurrentUser();

    // load in the test model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl
            .getResourceAsStream("org/alfresco/repo/search/impl/lucene/LuceneTest_model.xml");
    assertNotNull(modelStream);
    model = M2Model.createModel(modelStream);
    dictionaryDAO.registerListener(this);
    dictionaryDAO.reset();
    assertNotNull(dictionaryDAO.getClass(testSuperType));

    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE,
            "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);

    n1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"),
            testSuperType, getOrderProperties()).getChildRef();
    nodeService.setProperty(n1, QName.createQName("{namespace}property-1"), "ValueOne");

    n2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}two"),
            testSuperType, getOrderProperties()).getChildRef();
    nodeService.setProperty(n2, QName.createQName("{namespace}property-1"), "valueone");
    nodeService.setProperty(n2, QName.createQName("{namespace}property-2"), "valuetwo");

    n3 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}three"),
            testSuperType, getOrderProperties()).getChildRef();

    ObjectOutputStream oos;
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        oos = new ObjectOutputStream(baos);
        oos.writeObject(n3);
        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
        Object o = ois.readObject();
        ois.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>();
    testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"),
            "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYONE");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-unstored-tokenised-atomic"),
            "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYUNSTORED");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-nonatomic"),
            "TEXT THAT IS INDEXED STORED AND TOKENISED BUT NOT ATOMICALLY KEYTWO");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "int-ista"), Integer.valueOf(1));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "long-ista"), Long.valueOf(2));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "float-ista"), Float.valueOf(3.4f));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "double-ista"), Double.valueOf(5.6));
    //testDate = new Date(((new Date().getTime() - 10000)));
    Calendar c = new GregorianCalendar();
    c.setTime(new Date(((new Date().getTime() - 10000))));
    //c.add(Calendar.MINUTE, -1);
    //c.set(Calendar.MINUTE, 0);
    //c.set(Calendar.MILLISECOND, 999);
    //c.set(Calendar.SECOND, 1);
    //c.set(Calendar.MILLISECOND, 0);
    //c.set(Calendar.SECOND, 0);
    //c.set(Calendar.MINUTE, 0);
    //c.set(Calendar.HOUR_OF_DAY, 0);
    //        c.set(Calendar.YEAR, 2000);
    //        c.set(Calendar.MONTH, 12);
    //        c.set(Calendar.DAY_OF_MONTH, 31);
    //        c.set(Calendar.HOUR_OF_DAY, 23);
    //        c.set(Calendar.MINUTE, 59);
    //        c.set(Calendar.SECOND, 59);
    //        c.set(Calendar.MILLISECOND, 999);
    testDate = c.getTime();
    testProperties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "boolean-ista"), Boolean.valueOf(true));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "qname-ista"), QName.createQName("{wibble}wobble"));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "category-ista"), new NodeRef(storeRef, "CategoryId"));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "noderef-ista"), n1);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "path-ista"), nodeService.getPath(n3));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "locale-ista"), Locale.UK);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "period-ista"), new Period("period|12"));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "null"), null);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "list"), new ArrayList<Object>());
    MLText mlText = new MLText();
    mlText.addValue(Locale.ENGLISH, "banana");
    mlText.addValue(Locale.FRENCH, "banane");
    mlText.addValue(Locale.CHINESE, "");
    mlText.addValue(new Locale("nl"), "banaan");
    mlText.addValue(Locale.GERMAN, "banane");
    mlText.addValue(new Locale("el"), "");
    mlText.addValue(Locale.ITALIAN, "banana");
    mlText.addValue(new Locale("ja"), "?");
    mlText.addValue(new Locale("ko"), "");
    mlText.addValue(new Locale("pt"), "banana");
    mlText.addValue(new Locale("ru"), "");
    mlText.addValue(new Locale("es"), "pltano");
    testProperties.put(QName.createQName(TEST_NAMESPACE, "ml"), mlText);
    // Any multivalued
    ArrayList<Serializable> anyValues = new ArrayList<Serializable>();
    anyValues.add(Integer.valueOf(100));
    anyValues.add("anyValueAsString");
    anyValues.add(new UnknownDataType());
    testProperties.put(QName.createQName(TEST_NAMESPACE, "any-many-ista"), anyValues);
    // Content multivalued
    // - note only one the first value is used from the collection
    // - andit has to go in type d:any as d:content is not allowed to be multivalued

    ArrayList<Serializable> contentValues = new ArrayList<Serializable>();
    contentValues.add(new ContentData(null, "text/plain", 0L, "UTF-16", Locale.UK));
    testProperties.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), contentValues);

    // MLText multivalued

    MLText mlText1 = new MLText();
    mlText1.addValue(Locale.ENGLISH, "cabbage");
    mlText1.addValue(Locale.FRENCH, "chou");

    MLText mlText2 = new MLText();
    mlText2.addValue(Locale.ENGLISH, "lemur");
    mlText2.addValue(new Locale("ru"), "");

    ArrayList<Serializable> mlValues = new ArrayList<Serializable>();
    mlValues.add(mlText1);
    mlValues.add(mlText2);

    testProperties.put(QName.createQName(TEST_NAMESPACE, "mltext-many-ista"), mlValues);

    // null in multi valued

    ArrayList<Object> testList = new ArrayList<Object>();
    testList.add(null);
    testProperties.put(QName.createQName(TEST_NAMESPACE, "nullist"), testList);
    ArrayList<Object> testList2 = new ArrayList<Object>();
    testList2.add("woof");
    testList2.add(null);

    n4 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}four"),
            testType, testProperties).getChildRef();

    ContentWriter multiWriter = contentService.getWriter(n4,
            QName.createQName(TEST_NAMESPACE, "content-many-ista"), true);
    multiWriter.setEncoding("UTF-16");
    multiWriter.setMimetype("text/plain");
    multiWriter.putContent("multicontent");

    nodeService.getProperties(n1);
    nodeService.getProperties(n2);
    nodeService.getProperties(n3);
    nodeService.getProperties(n4);

    n5 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}five"), testSuperType,
            getOrderProperties()).getChildRef();
    n6 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}six"), testSuperType,
            getOrderProperties()).getChildRef();
    n7 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}seven"), testSuperType,
            getOrderProperties()).getChildRef();
    n8 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-2"), testSuperType,
            getOrderProperties()).getChildRef();
    n9 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}nine"), testSuperType,
            getOrderProperties()).getChildRef();
    n10 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}ten"), testSuperType,
            getOrderProperties()).getChildRef();
    n11 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eleven"), testSuperType,
            getOrderProperties()).getChildRef();
    n12 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}twelve"), testSuperType,
            getOrderProperties()).getChildRef();
    n13 = nodeService.createNode(n12, ASSOC_TYPE_QNAME, QName.createQName("{namespace}thirteen"), testSuperType,
            getOrderProperties()).getChildRef();

    Map<QName, Serializable> properties = new HashMap<QName, Serializable>();

    MLText desc1 = new MLText();
    desc1.addValue(Locale.ENGLISH, "Alfresco tutorial");
    desc1.addValue(Locale.US, "Alfresco tutorial");

    Date explicitCreatedDate = new Date();
    Thread.sleep(2000);

    properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK));
    properties.put(ContentModel.PROP_DESCRIPTION, desc1);
    properties.put(ContentModel.PROP_CREATED, explicitCreatedDate);

    //Calendar c = new GregorianCalendar();
    //c.setTime(new Date());
    //c.set(Calendar.MILLISECOND, 0);
    //c.set(Calendar.SECOND, 0);
    //c.set(Calendar.MINUTE, 0);
    //c.set(Calendar.HOUR_OF_DAY, 0);
    //testDate = c.getTime();
    //properties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate);
    //properties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate);

    // note: cm:content - hence auditable aspect will be applied with any missing mandatory properties (cm:modified, cm:creator, cm:modifier)
    n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"),
            ContentModel.TYPE_CONTENT, properties).getChildRef();
    // nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT,
    // properties);

    assertEquals(explicitCreatedDate, nodeService.getProperty(n14, ContentModel.PROP_CREATED));

    // note: cm:thumbnail - hence auditable aspect will be applied with mandatory properties (cm:created, cm:modified, cm:creator, cm:modifier)
    n15 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fifteen"),
            ContentModel.TYPE_THUMBNAIL, getOrderProperties()).getChildRef();
    nodeService.setProperty(n15, ContentModel.PROP_CONTENT,
            new ContentData(null, "text/richtext", 0L, "UTF-8", Locale.FRENCH));

    ContentWriter writer = contentService.getWriter(n14, ContentModel.PROP_CONTENT, true);
    writer.setEncoding("UTF-8");
    // InputStream is =
    // this.getClass().getClassLoader().getResourceAsStream("test.doc");
    // writer.putContent(is);
    writer.putContent(
            "The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words;  a an and are"
                    + " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: "
                    + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF");
    // System.out.println("Size is " + writer.getSize());

    writer = contentService.getWriter(n15, ContentModel.PROP_CONTENT, true);
    writer.setEncoding("UTF-8");
    // InputStream is =
    // this.getClass().getClassLoader().getResourceAsStream("test.doc");
    // writer.putContent(is);
    writer.putContent("          ");

    nodeService.addChild(rootNodeRef, n8, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}eight-0"));
    nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-1"));
    nodeService.addChild(n2, n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}link"));

    nodeService.addChild(n1, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n2, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n5, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n6, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n12, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));
    nodeService.addChild(n13, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common"));

    documentOrder = new NodeRef[] { rootNodeRef, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n3, n1,
            n2 };
}

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

public boolean openAsStatements(Statements statements, File file) {
    assert (statements != null);

    if (statements.getType() == Statement.Type.PortfolioManagementBuy
            || statements.getType() == Statement.Type.PortfolioManagementSell
            || statements.getType() == Statement.Type.PortfolioManagementDeposit
            || statements.getType() == Statement.Type.PortfolioManagementDividend) {
        final GUIBundleWrapper guiBundleWrapper = statements.getGUIBundleWrapper();
        // We will use a fixed date format (Locale.English), so that it will be
        // easier for Android to process.
        ////from  www . j  a v a2 s  .c  o  m
        // "Sep 5, 2011"    -   Locale.ENGLISH
        // "2011-9-5"       -   Locale.SIMPLIFIED_CHINESE
        // "2011/9/5"       -   Locale.TRADITIONAL_CHINESE
        // 05.09.2011       -   Locale.GERMAN
        //
        // However, for backward compatible purpose (Able to read old CSV),
        // we perform a for loop to determine the best date format.
        DateFormat dateFormat = null;
        final int size = statements.size();
        switch (statements.getType()) {
        case PortfolioManagementBuy: {
            final List<Transaction> transactions = new ArrayList<Transaction>();

            for (int i = 0; i < size; i++) {
                final Statement statement = statements.get(i);
                final String _code = statement.getValueAsString(guiBundleWrapper.getString("MainFrame_Code"));
                final String _symbol = statement
                        .getValueAsString(guiBundleWrapper.getString("MainFrame_Symbol"));
                final String _date = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date"));
                final Double units = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Units"));
                final Double purchasePrice = statement.getValueAsDouble(
                        guiBundleWrapper.getString("PortfolioManagementJPanel_PurchasePrice"));
                final Double broker = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Broker"));
                final Double clearingFee = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_ClearingFee"));
                final Double stampDuty = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_StampDuty"));
                final String _comment = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment"));

                Stock stock = null;
                if (_code.length() > 0 && _symbol.length() > 0) {
                    stock = org.yccheok.jstock.engine.Utils.getEmptyStock(Code.newInstance(_code),
                            Symbol.newInstance(_symbol));
                } else {
                    log.error("Unexpected empty stock. Ignore");
                    // stock is null.
                    continue;
                }
                Date date = null;

                if (dateFormat == null) {
                    // However, for backward compatible purpose (Able to read old CSV),
                    // we perform a for loop to determine the best date format.
                    // For the latest CSV, it should be Locale.ENGLISH.
                    Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN,
                            Locale.TRADITIONAL_CHINESE, Locale.ITALIAN };
                    for (Locale locale : locales) {
                        dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
                        try {
                            date = dateFormat.parse((String) _date);
                        } catch (ParseException exp) {
                            log.error(null, exp);
                            date = null;
                            dateFormat = null;
                            continue;
                        }
                        // We had found our best dateFormat. Early break.
                        break;
                    }
                } else {
                    // We already determine our best dateFormat.
                    try {
                        date = dateFormat.parse((String) _date);
                    } catch (ParseException exp) {
                        log.error(null, exp);
                    }
                }

                if (date == null) {
                    log.error("Unexpected wrong date. Ignore");
                    continue;
                }

                // Shall we continue to ignore, or shall we just return false to
                // flag an error?
                if (units == null) {
                    log.error("Unexpected wrong units. Ignore");
                    continue;
                }
                if (purchasePrice == null || broker == null || clearingFee == null || stampDuty == null) {
                    log.error("Unexpected wrong purchasePrice/broker/clearingFee/stampDuty. Ignore");
                    continue;
                }

                final SimpleDate simpleDate = new SimpleDate(date);
                final Contract.Type type = Contract.Type.Buy;
                final Contract.ContractBuilder builder = new Contract.ContractBuilder(stock, simpleDate);
                final Contract contract = builder.type(type).quantity(units).price(purchasePrice).build();
                final Transaction t = new Transaction(contract, broker, stampDuty, clearingFee);
                t.setComment(org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(_comment));
                transactions.add(t);
            }

            // We allow empty portfolio.
            //if (transactions.size() <= 0) {
            //    return false;
            //}

            // Is there any exsiting displayed data?
            if (this.getBuyTransactionSize() > 0) {
                final String output = MessageFormat.format(
                        MessagesBundle.getString("question_message_load_file_for_buy_portfolio_template"),
                        file.getName());
                final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output,
                        MessagesBundle.getString("question_title_load_file_for_buy_portfolio"),
                        javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
                if (result != javax.swing.JOptionPane.YES_OPTION) {
                    // Assume success.
                    return true;
                }
            }

            this.buyTreeTable.setTreeTableModel(new BuyPortfolioTreeTableModelEx());
            final BuyPortfolioTreeTableModelEx buyPortfolioTreeTableModel = (BuyPortfolioTreeTableModelEx) buyTreeTable
                    .getTreeTableModel();
            buyPortfolioTreeTableModel.bind(this.portfolioRealTimeInfo);
            buyPortfolioTreeTableModel.bind(this);

            Map<String, String> metadatas = statements.getMetadatas();
            for (Transaction transaction : transactions) {
                final Code code = transaction.getStock().code;
                TransactionSummary transactionSummary = this.addBuyTransaction(transaction);
                if (transactionSummary != null) {
                    String comment = metadatas.get(code.toString());
                    if (comment != null) {
                        transactionSummary.setComment(
                                org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment));
                    }
                }
            }

            // Only shows necessary columns.
            initGUIOptions();

            expandTreeTable(buyTreeTable);

            updateRealTimeStockMonitorAccordingToPortfolioTreeTableModels();
            updateExchangeRateMonitorAccordingToPortfolioTreeTableModels();

            // updateWealthHeader will be called at end of switch.

            refreshStatusBarExchangeRateVisibility();
        }
            break;

        case PortfolioManagementSell: {
            final List<Transaction> transactions = new ArrayList<Transaction>();

            for (int i = 0; i < size; i++) {
                final Statement statement = statements.get(i);
                final String _code = statement.getValueAsString(guiBundleWrapper.getString("MainFrame_Code"));
                final String _symbol = statement
                        .getValueAsString(guiBundleWrapper.getString("MainFrame_Symbol"));
                final String _referenceDate = statement.getValueAsString(
                        guiBundleWrapper.getString("PortfolioManagementJPanel_ReferenceDate"));

                // Legacy file handling. PortfolioManagementJPanel_PurchaseBroker, PortfolioManagementJPanel_PurchaseClearingFee,
                // and PortfolioManagementJPanel_PurchaseStampDuty are introduced starting from 1.0.6x
                Double purchaseBroker = statement.getValueAsDouble(
                        guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseBroker"));
                if (purchaseBroker == null) {
                    // Legacy file handling. PortfolioManagementJPanel_PurchaseFee is introduced starting from 1.0.6s
                    purchaseBroker = statement.getValueAsDouble(
                            guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseFee"));
                    if (purchaseBroker == null) {
                        purchaseBroker = new Double(0.0);
                    }
                }
                Double purchaseClearingFee = statement.getValueAsDouble(
                        guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseClearingFee"));
                if (purchaseClearingFee == null) {
                    purchaseClearingFee = new Double(0.0);
                }
                Double purchaseStampDuty = statement.getValueAsDouble(
                        guiBundleWrapper.getString("PortfolioManagementJPanel_PurchaseStampDuty"));
                if (purchaseStampDuty == null) {
                    purchaseStampDuty = new Double(0.0);

                }
                final String _date = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date"));
                final Double units = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Units"));
                final Double sellingPrice = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_SellingPrice"));
                final Double purchasePrice = statement.getValueAsDouble(
                        guiBundleWrapper.getString("PortfolioManagementJPanel_PurchasePrice"));
                final Double broker = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Broker"));
                final Double clearingFee = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_ClearingFee"));
                final Double stampDuty = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_StampDuty"));
                final String _comment = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment"));

                Stock stock = null;
                if (_code.length() > 0 && _symbol.length() > 0) {
                    stock = org.yccheok.jstock.engine.Utils.getEmptyStock(Code.newInstance(_code),
                            Symbol.newInstance(_symbol));
                } else {
                    log.error("Unexpected empty stock. Ignore");
                    // stock is null.
                    continue;
                }

                Date date = null;
                Date referenceDate = null;

                if (dateFormat == null) {
                    // However, for backward compatible purpose (Able to read old CSV),
                    // we perform a for loop to determine the best date format.
                    // For the latest CSV, it should be Locale.ENGLISH.
                    Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN,
                            Locale.TRADITIONAL_CHINESE, Locale.ITALIAN };
                    for (Locale locale : locales) {
                        dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
                        try {
                            date = dateFormat.parse((String) _date);
                            referenceDate = dateFormat.parse((String) _referenceDate);
                        } catch (ParseException exp) {
                            log.error(null, exp);
                            date = null;
                            referenceDate = null;
                            dateFormat = null;
                            continue;
                        }
                        // We had found our best dateFormat. Early break.
                        break;
                    }
                } else {
                    // We already determine our best dateFormat.
                    try {
                        date = dateFormat.parse((String) _date);
                        referenceDate = dateFormat.parse((String) _referenceDate);
                    } catch (ParseException exp) {
                        log.error(null, exp);
                    }
                }

                if (date == null || referenceDate == null) {
                    log.error("Unexpected wrong date/referenceDate. Ignore");
                    continue;
                }
                // Shall we continue to ignore, or shall we just return false to
                // flag an error?
                if (units == null) {
                    log.error("Unexpected wrong units. Ignore");
                    continue;
                }
                if (purchasePrice == null || broker == null || clearingFee == null || stampDuty == null
                        || sellingPrice == null) {
                    log.error(
                            "Unexpected wrong purchasePrice/broker/clearingFee/stampDuty/sellingPrice. Ignore");
                    continue;
                }

                final SimpleDate simpleDate = new SimpleDate(date);
                final SimpleDate simpleReferenceDate = new SimpleDate(referenceDate);
                final Contract.Type type = Contract.Type.Sell;
                final Contract.ContractBuilder builder = new Contract.ContractBuilder(stock, simpleDate);
                final Contract contract = builder.type(type).quantity(units).price(sellingPrice)
                        .referencePrice(purchasePrice).referenceDate(simpleReferenceDate)
                        .referenceBroker(purchaseBroker).referenceClearingFee(purchaseClearingFee)
                        .referenceStampDuty(purchaseStampDuty).build();
                final Transaction t = new Transaction(contract, broker, stampDuty, clearingFee);
                t.setComment(org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(_comment));
                transactions.add(t);
            } // for

            // We allow empty portfolio.
            //if (transactions.size() <= 0) {
            //    return false;
            //}

            // Is there any exsiting displayed data?
            if (this.getSellTransactionSize() > 0) {
                final String output = MessageFormat.format(
                        MessagesBundle.getString("question_message_load_file_for_sell_portfolio_template"),
                        file.getName());
                final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output,
                        MessagesBundle.getString("question_title_load_file_for_sell_portfolio"),
                        javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
                if (result != javax.swing.JOptionPane.YES_OPTION) {
                    // Assume success.
                    return true;
                }
            }

            this.sellTreeTable.setTreeTableModel(new SellPortfolioTreeTableModelEx());
            final SellPortfolioTreeTableModelEx sellPortfolioTreeTableModel = (SellPortfolioTreeTableModelEx) sellTreeTable
                    .getTreeTableModel();
            sellPortfolioTreeTableModel.bind(this.portfolioRealTimeInfo);
            sellPortfolioTreeTableModel.bind(this);

            Map<String, String> metadatas = statements.getMetadatas();

            for (Transaction transaction : transactions) {
                final Code code = transaction.getStock().code;
                TransactionSummary transactionSummary = this.addSellTransaction(transaction);
                if (transactionSummary != null) {
                    String comment = metadatas.get(code.toString());
                    if (comment != null) {
                        transactionSummary.setComment(
                                org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment));
                    }
                }
            }

            // Only shows necessary columns.
            initGUIOptions();

            expandTreeTable(this.sellTreeTable);

            updateExchangeRateMonitorAccordingToPortfolioTreeTableModels();

            // updateWealthHeader will be called at end of switch.

            refreshStatusBarExchangeRateVisibility();
        }
            break;

        case PortfolioManagementDeposit: {
            final List<Deposit> deposits = new ArrayList<Deposit>();

            for (int i = 0; i < size; i++) {
                Date date = null;
                final Statement statement = statements.get(i);
                final String object0 = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date"));
                assert (object0 != null);

                if (dateFormat == null) {
                    // However, for backward compatible purpose (Able to read old CSV),
                    // we will perform a for loop to determine the best date format.
                    // For the latest CSV, it should be Locale.ENGLISH.
                    Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN,
                            Locale.TRADITIONAL_CHINESE, Locale.ITALIAN };
                    for (Locale locale : locales) {
                        dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
                        try {
                            date = dateFormat.parse(object0);
                        } catch (ParseException exp) {
                            log.error(null, exp);
                            date = null;
                            dateFormat = null;
                            continue;
                        }
                        // We had found our best dateFormat. Early break.
                        break;
                    }
                } else {
                    // We already determine our best dateFormat.
                    try {
                        date = dateFormat.parse(object0);
                    } catch (ParseException exp) {
                        log.error(null, exp);
                    }
                }

                // Shall we continue to ignore, or shall we just return false to
                // flag an error?
                if (date == null) {
                    log.error("Unexpected wrong date. Ignore");
                    continue;
                }
                final Double cash = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Cash"));
                // Shall we continue to ignore, or shall we just return false to
                // flag an error?
                if (cash == null) {
                    log.error("Unexpected wrong cash. Ignore");
                    continue;
                }
                final Deposit deposit = new Deposit(cash, new SimpleDate(date));

                final String comment = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment"));
                if (comment != null) {
                    // Possible to be null. As in version <=1.0.6p, comment
                    // is not being saved to CSV.
                    deposit.setComment(
                            org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment));
                }

                deposits.add(deposit);
            }

            // We allow empty portfolio.
            //if (deposits.size() <= 0) {
            //    return false;
            //}

            // Is there any exsiting displayed data?
            if (this.depositSummary.size() > 0) {
                final String output = MessageFormat.format(
                        MessagesBundle.getString("question_message_load_file_for_cash_deposit_template"),
                        file.getName());
                final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output,
                        MessagesBundle.getString("question_title_load_file_for_cash_deposit"),
                        javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
                if (result != javax.swing.JOptionPane.YES_OPTION) {
                    // Assume success.
                    return true;
                }
            }

            this.depositSummary = new DepositSummary();

            for (Deposit deposit : deposits) {
                depositSummary.add(deposit);
            }
        }
            break;

        case PortfolioManagementDividend: {
            final List<Dividend> dividends = new ArrayList<Dividend>();

            for (int i = 0; i < size; i++) {
                Date date = null;
                StockInfo stockInfo = null;
                final Statement statement = statements.get(i);
                final String object0 = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Date"));
                assert (object0 != null);

                if (dateFormat == null) {
                    // However, for backward compatible purpose (Able to read old CSV),
                    // we will perform a for loop to determine the best date format.
                    // For the latest CSV, it should be Locale.ENGLISH.
                    Locale[] locales = { Locale.ENGLISH, Locale.SIMPLIFIED_CHINESE, Locale.GERMAN,
                            Locale.TRADITIONAL_CHINESE, Locale.ITALIAN };
                    for (Locale locale : locales) {
                        dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
                        try {
                            date = dateFormat.parse(object0);
                        } catch (ParseException exp) {
                            log.error(null, exp);
                            date = null;
                            dateFormat = null;
                            continue;
                        }
                        // We had found our best dateFormat. Early break.
                        break;
                    }
                } else {
                    // We already determine our best dateFormat.
                    try {
                        date = dateFormat.parse(object0);
                    } catch (ParseException exp) {
                        log.error(null, exp);
                    }
                }

                // Shall we continue to ignore, or shall we just return false to
                // flag an error?
                if (date == null) {
                    log.error("Unexpected wrong date. Ignore");
                    continue;
                }
                final Double dividend = statement
                        .getValueAsDouble(guiBundleWrapper.getString("PortfolioManagementJPanel_Dividend"));
                // Shall we continue to ignore, or shall we just return false to
                // flag an error?
                if (dividend == null) {
                    log.error("Unexpected wrong dividend. Ignore");
                    continue;
                }
                final String codeStr = statement.getValueAsString(guiBundleWrapper.getString("MainFrame_Code"));
                final String symbolStr = statement
                        .getValueAsString(guiBundleWrapper.getString("MainFrame_Symbol"));
                if (codeStr.isEmpty() == false && symbolStr.isEmpty() == false) {
                    stockInfo = StockInfo.newInstance(Code.newInstance(codeStr), Symbol.newInstance(symbolStr));
                } else {
                    log.error("Unexpected wrong stock. Ignore");
                    // stock is null.
                    continue;
                }

                assert (stockInfo != null);
                assert (dividend != null);
                assert (date != null);

                final Dividend d = new Dividend(stockInfo, dividend, new SimpleDate(date));

                final String comment = statement
                        .getValueAsString(guiBundleWrapper.getString("PortfolioManagementJPanel_Comment"));
                if (comment != null) {
                    // Possible to be null. As in version <=1.0.6p, comment
                    // is not being saved to CSV.
                    d.setComment(
                            org.yccheok.jstock.portfolio.Utils.replaceCSVLineFeedToSystemLineFeed(comment));
                }

                dividends.add(d);
            }

            // We allow empty portfolio.
            //if (dividends.size() <= 0) {
            //    return false;
            //}                    

            if (this.dividendSummary.size() > 0) {
                final String output = MessageFormat.format(
                        MessagesBundle.getString("question_message_load_file_for_dividend_template"),
                        file.getName());
                final int result = javax.swing.JOptionPane.showConfirmDialog(JStock.instance(), output,
                        MessagesBundle.getString("question_title_load_file_for_dividend"),
                        javax.swing.JOptionPane.YES_NO_OPTION, javax.swing.JOptionPane.QUESTION_MESSAGE);
                if (result != javax.swing.JOptionPane.YES_OPTION) {
                    // Assume success.
                    return true;
                }
            }

            this.dividendSummary = new DividendSummary();

            for (Dividend dividend : dividends) {
                dividendSummary.add(dividend);
            }
        }
            break;

        default:
            assert (false);
        } // End of switch

        this.updateWealthHeader();
    } else if (statements.getType() == Statement.Type.RealtimeInfo) {
        /* Open using other tabs. */
        return JStock.instance().openAsStatements(statements, file);
    } else {
        return false;
    }
    return true;
}

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

/** This method is called from within the constructor to
 * initialize the form.//from w ww.  j av a  2  s.c om
 * 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.//  w ww  . j a  v  a  2s . c o 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.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests.java

@Test
public void localeCharsetMappingsAreConfigured() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    Map<Locale, Charset> mappings = new HashMap<>();
    mappings.put(Locale.GERMAN, Charset.forName("UTF-8"));
    factory.setLocaleCharsetMappings(mappings);
    this.webServer = factory.getWebServer();
    assertThat(getCharset(Locale.GERMAN).toString()).isEqualTo("UTF-8");
    assertThat(getCharset(Locale.ITALIAN)).isNull();
}

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 w  ww .ja  va  2  s. com
 * @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  ww  .  j  ava2 s  . 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);
            }
        }
    }
}